Sep 16 2022 12:06 PM
I am working with categorical data - think of a survey with ratings from 1 to 5. In addition to the counts and grand total, I need to be able to add a percentage to summarize the top two categories.
Example (trying to add the %):
Poor | Fair | Neutral | Good | Excellent | Total | %Top 2 | ||
Jan | 3 | 3 | 3 | 4 | 4 | 17 | 47% | |
Feb | 1 | 1 | 4 | 4 | 5 | 15 | 60% | |
Mar | 2 | 6 | 9 | 17 | 88% | |||
Apr | 1 | 2 | 2 | 6 | 5 | 16 | 69% | |
Total | 5 | 6 | 11 | 20 | 23 | 65 | 66% |
My true data includes several nested groupings in the rows, so it would make things much easier if I could add this into the pivot table rather than just having a manual calculation off to the right. That would accommodate new groupings that might appear or expanding/collapsing sub-grouping automatically.
I could easily add a column in my raw data to identify if the rating was in the top categories (1) or not (0). However, I am still unsure how to add it without having it nest within the rating categories. Ideas?
Sep 17 2022 07:43 AM - edited Sep 17 2022 09:55 AM
With the AGGREGATE() or the LARGE() function you can display the two top values and sum them up. Then just divide by the sum and make it a percentage.
See also the enclosed document.
=SUM(AGGREGATE(14,6,B2:F2,{1,2}))/SUM(B2:F2)
It's not a pivot table. I hope you like it anyway.
The LAGRGE() function leads to the same result.
=SUM(LARGE(B2:F2,{1,2}))/SUM(B2:F2)