Percentage value out of total value on all rows

Your need is the same as the one in the post linked below. The problem is generating the total sum of the column to calculate the percentage. In SQL you use a window function to add a total sum column that you use in the percentage calculation.

Since this post, Metabase 56 added custom expressions for join conditions in the query editor. It is now possible to cross join 2 questions with a 1=1 condition, so the difficulty in the post has been (conceptually) solved. On the downside, the query performance will be poor as it will take 2 passes through the data, one to calculate the total sum and another to calculate the percentage.

The assumption is that you want the percentage calculated using the rows visible in the sandbox. If you need the total sum including rows outside the sandbox, you’ll need to calculate it in the database itself, in a way that won’t get limited by the RLS predicate.

I’ll update this thread later with a howto.