Percent in total for a measure which is already a measure in different view

done
normal_priority
reply

(Lakshmi Prasanna) #1

In my scenario, I need to get sum of Total_Orders group by supplier_name. And at the same time, I need to calculate how much percent in total does this sum of Total_Orders cover for each supplier_name dimension. Can you please help how to achieve.

I am using snowflake database.
The above case when it is written in sql it should act like

select supplier_name,sum(order_total),sum(order_total)/(select sum(order_total) from orders) as order_total_percent from orders group by supplier_name;

But I am not able to get the same scenario in looker. Please help.


(Izzy) #2

There’s a few different ways to go about percent of total in Looker-- one is with table calculations, which means you wouldn’t actually need to go int othe lookml/sql. We outline a solid approach here: How to Calculate Percent of Total.

You could also use the percent_of_total measure type: https://docs.looker.com/reference/field-reference/measure-type-reference#percent_of_total which achieves pretty much the same goal, with LookML. The choice is up to you!


(Lakshmi Prasanna) #3

Thanks Izzy. I got it solved.