Bug description
Bug description Problem 1: The percentage calculation in tables that use pagination is not based on the total number of rows, but only on the rows displayed on that page. This means that the percentage calculation is always incorrect.
Problem 2: Still related to the percentage calculation issue, Superset appears to be unable to correctly group the fields on which to calculate. If I use a graph to explain the information, I get a tooltip that's consistent with the expected results. If I report the data in tabular form, I get an incorrect calculation.
Chart and tooltip:
Result:
Table definition:
Screenshots/recordings
No response
Superset version
4.1.3
Python version
I don't know
Node version
I don't know
Browser
Chrome
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
Hi @gcofini! I'm Dosu and I’m helping the superset team.
This happens because, by default, percentage calculations in Superset tables are based only on the rows currently displayed (the page or row limit), not the entire dataset. This is controlled by the "Percentage metric calculation" setting in the Table chart panel, which defaults to "Row limit". As a result, percentages in paginated tables are often incorrect unless you change this setting.
Charts and tooltips, on the other hand, aggregate over the full dataset, so their percentage calculations are accurate and reflect the total data, not just what's visible on the current page.
To fix this in your table, set "Percentage metric calculation" to "All records" in the Table chart controls. This will make Superset issue an extra query to calculate percentages based on the entire dataset, giving you correct results in the table as well. Be aware that this can have a performance impact on very large datasets, since it requires an additional query over all records.
You can find more details in the Superset table chart control panel code and the query logic for percentage metrics. This behavior is by design and not a bug, but it can be confusing if you're expecting percent-of-total to always reflect the full dataset in tables.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
Comment From: rusackas
I think the bot may be right, but let us know if you find otherwise:
Of course, if you give us a chart config using example datasets, this would be easier to help debug.