Aggregate Totals Using a Calculation

  • 14 February 2019
  • 3 replies

Hi there,

I noticed there was a post awhile ago which asked how to aggregate the categories for fruit. I tried to follow this in my calculation, however the calculation doesn’t want to work because I am giving the expression 4 arguments over 3.

My data looks like the following:













I want to calc the total number of promoters, detractors and passives and put this on a stacked bar chart to show distribution.

I am not sure if this is possible via calculations but I do not have access to lookml and I am fairly new to Looker.

Any help would be much appreciated!

3 replies

Userlevel 3


I assume the table you have shown us is the output from a query on the explore page?

I think if you click ‘pivot’ on the ‘NPS Ordinal’ field that will allow you to build the chart you want. You can then select bar chart, edit, stacked.


Hi Andrew,

Thanks for the response!

So I want my data to show the % stacked distribution for Promoters (5879/9129=64.4%), Detractors (2088/9129=22.9%) and Passives(1162/9129=12.7%). If I pivot on NPS ORDINAL (dimension), it just buckets by the numerical spread 0 - 10 and ignores the NPS NESTED CALC (calculation).

Userlevel 3

Apologies, misunderstood the requirement.

I think this is a case where you should ask your developers to include it in the model instead. There’s something you could do with Custom Dimensions if you have that enabled, but I think that would be inappropriate in this case.

They should be able to create a new dimension which applies the same logic you are using in your table calculation. This is fairly standard logic that I’m sure will be beneficial to many other people. Table calculations and Custom dimensions are great but they only exist in the explore that created them, adding them to the model makes them re-usable in many different contexts.