Score:0

Combine Aggregation with Pivot Table in Drupal Views

ro flag

I have some views that use pivot tables. Their purpose is to display an attribute (for example, the gender) and a year value (for example, the birth year), using a third field named ID. The gender is used as pivot row and the birth year as pivot column. ID has the Aggregation type "Count". Additionally, we have a Total column for the row aggregate (number of values in Pivot settings) that counts how many people have a specific gender.

In this table, it's possible for a listed person to have an unknown year of birth. Therefore, I set the No results behavior for Birth year to unknown. That value is correctly shown as just another column.

Now I have a problem: Drupal doesn't count the row with unknown as birth year. It seems that it puts 1 inside the cell for female + unknown if there is one or more people with female as gender and unknown as birth year (no results behavior), but it doesn't count them.

Anyone has any hint on where I can determine how Drupal pivot tables work with No results behavior?

Edit @apaderno: In my opinion, this is not a request for documentation, but a question about a possible bug or at least bug-like behavior in the Drupal GUI. The phrasing "Anybody has any hint" may seem vague, but I had some positive experiences with that on other Stackexchange sites in the network, as it encouraged users to add their knowledge to the thread, even if it wasn't a complete answer to the question. I got some valuable hints this way in the past.

Edit2: When I change the Aggregation setting of the ID field to "Count Distinct", the No results behavior is counted correctly, but the row aggregate (as well as column aggregate) stops working correctly.

apaderno avatar
us flag
*Anyone has any hint on where I can determine how Drupal pivot tables work with No results behavior?* seems a request for documentation, which is off-topic for us. If the question isn't about that, please edit it to make it clearer. Bear in mind that questions like *Did anybody get the same problem?* are too broad to be acceptable.
Score:0
ro flag

It seems that this problem didn't occur only with No Results Behavior but with any value above 1 (being reduced to 1).

I solved the problem by adding the ID field as a Sort Criteria in the Drupal view. (The other fields stay without Aggregation, that is, the default value "Group Results By". In the Pivot settings, I kept the Row Aggregate of the ID field being "number of values".)

I have no idea how/why the Sort Criteria could possibly effect the counting results of the Pivot table, but they did.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.