Percent of subtotals

(Carly K) #1

Is there a way to do a percent of a subtotal in a table calculation or LookML?

(jonathon) #2

Hey @carlyk! Thanks for the question. You can reference the Totals and Row Totals fields in a table calc by appending :total or :row_total to the field in the substitution operators like so:


The percent formatting options are available via the drop-down in the table calc:

The Explore Results look like:

(Brett M) #3

Hey @jonathon – just getting started with Looker here, and found this thread very helpful.

As a follow-up, is there a way to get looker to also calculate the percent of the row total for the summary row? For example, the “No” total column is 25,278 and the “Yes” total column is 798, but the percent of the row table calculation is blank for the totals. Is there a way to get that to fill in, or can it be populated with a separate table calculation?


(Talal) #4

Hey @bmadres,

We’re excited you’re already building stuff with Looker! We currently cannot display totals of table calculations. One of the main reasons for that is the confusion it might create in whether they’re totals for the series above or for the measure totals. It’s definitely on the radar of the product team, and I’ve added your feedback to that as well.

Meanwhile, one way to get around it is to sum all the counts and get a percentage out of that. I’ve added the code below. It won’t be ideal because you’ll end up with an entire column of the same value. If you’d like any additional help with working towards a different result, please send us an email at, and we’ll be happy to assist.

sum(pivot_where(${order_items.returned} = yes, ${products.count}))/ sum(pivot_where(${order_items.returned} = no, ${products.count}))