Feature Request : currently we can't summarize pivot table/ table as % value of row total/ column total/ grand total
Make sure these boxes are checked before submitting your issue - thank you!
- [Y ] I have checked the superset logs for python stacktraces and included it here as text if any
- [ Y] I have reproduced the issue with at least the latest released version of superset
- [ Y] I have checked the issue tracker for the same issue and I haven't found one similar
Can we add a feature in visualization type "treemap", "pivot table","table" and "partition" which enable us to summarize data by % total of row total or column total or grand total
Superset version
Expected results
Actual results
Steps to reproduce
How does this compare to the existing Percent Metrics feature in the table vis?
Is "percent metric" option is available in "pivot table" also?
Is "percent metric" option is available in "pivot table" also?
Not currently
This would be a useful feature to greatly extend the expressiveness of the pivot table chart, i.e., to represent "wide" vs "long" data.
To illustrate, suppose have data for school students with a letter grade for each subject. Further suppose that we would like to calculate the count by subject and grade. In this case, we can use either visualization type:
Table View
| subject | grade | count |
|---|---|---|
| English | A | 50 |
| English | B | 85 |
| English | C | 39 |
| English | D | 12 |
| English | F | 0 |
| Math | A | 44 |
| ... | ... | ... |
Pivot Table
| subject | A | B | C | D | F | all |
|---|---|---|---|---|---|---|
| English | 50 | 85 | 39 | 12 | 0 | 186 |
| Math | 44 | ... | ... | ... | ... | ... |
| ... | ... | ... | ... | ... | ... | ... |
If we now would like to see the percentage of students by letter grade within each subject, we are out of luck. Table View exposes "Percentage Metrics", but the percentages use the number of students across all subjects and letter grades as the denominator.
If, on the other hand, "Percentage Metrics" were implemented for Pivot Table and this added a percentage for each column calculated over the row total, we would be able to express the ask.
In any case, this would be a useful feature (although I'm sure there are design/implementation details to nail down), and hopefully the example above illustrates how such a feature would extend Superset's expressiveness in tabular "visualizations" even further.
Is anyone working on this,is there a way to implement "Percentage Metrics" .i am new to superset so i need help.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.
Is anyone working on this?
Anyone found way to do this?
@sahildoshi013 have you tried out "Pivot table v2"? It has an option to calculate percentages over row/column/total.
@villebro Thanks, I am able to calculate percentages. but is there any way I can plot sum and percentage both at same time. just like normal table?
@sahildoshi013 unfortunately it's not yet possible to apply this logic per metric. However, in the meantime, you can create a secondary metric where you apply a window function where you divide your aggregate expression with the total for that row (feel free to customize the window function to your use case):
- First metric:
COUNT(*) - Second metric:
1.0 * COUNT(*) / SUM(COUNT(*)) OVER ()
perfect! For the percentage column - for example profit - I used the expression below for percentages:
100 * sum(profit) / sum(sum(profit)) OVER ()
As the values in the cells grow larger and larger, having a percentage metric with the count would be very helpful for analysis.