Skip to main content

Percent of column total

The percent of the column total will give you the percentage of each value in the column out of the total sum of the values in the column.

Just gimme the code! ๐Ÿ‘พ

Here's an example of a percent of the total column:

And here's the SQL used in the table calculation:

${pages.page_view_count} * 100 / SUM(${pages.page_view_count}) OVER()

In general, the SQL used for calculating the percent of the total has just one important column:

  • column_i_want_to_see_the_percent_of_total - this is the column that you want to see each value's percent of the total values in that column

๐Ÿ‘€ Here's the SQL you can copy-paste to calculate the percent of the column totalโ€‹

${table.column_i_want_to_see_the_percent_of_total} * 100 / 
SUM(${table.column_i_want_to_see_the_percent_of_total}) OVER()

๐Ÿ’Ž Level up your SQL:

  • You can round your table calculation to only show a certain number of decimal points. Here's an example where I only show two decimal points:

    ROUND(${table.column_i_want_to_see_the_percent_of_total} * 100 / SUM(${table. column_i_want_to_see_the_percent_of_total}) OVER(), 2)