percent_of_total Question

kuopaz
New Member

From the docs:
“percent_of_total calculates a cell’s portion of the column total. The percentage is calculated against the total of the rows returned by your query, and not the total of all possible rows.”

Say I have a query that returns 100 rows. I want to show the top 10, so order the column and then set the row limit to 10. But as said, the percentage is calculated on the 10 rows returned. Is it possible to get the percentage based on the original 100 rows, but still show only the top 10 rows?

0 4 740
4 REPLIES 4

Yes, you can order your data results table accordingly and then use sum(if(row() <= 10, ${measure}, null)) such Table Calculation would give you total of the top 10 rows and then you can create another one with % of that total

Most visualization types have a ‘Limit displayed rows’ option so that you can show only the top x rows in the visualization, independent of the number of rows in the result set:

kuopaz
New Member

Thanks Rufus! Found it.

How would you do it if you needed to group the rest of values into "Others". So show the percent of total of the first 10 values and the rest of the values under "Others" label?

Top Labels in this Space
Top Solution Authors