What is the most efficient way in Looker to use table calculation functions to do aggregates?
- Looker FAQs
- January 21, 2018
Let us consider a scenario where we have a table in Looker that contains individual orders for every store. Now we want to fetch the max. and min. order value on a monthly/quarterly/yearly basis.
To achieve this, we could use pivoting by store and month for partitioning the data and accomplish what’s required in one Table Calculation as follows in Looker:
Solution :
We can use pivoting for partitioning, so we could accomplish what is required above in one calc with by pivoting store and month doing the following in Looker :
max(if (diff_months( ${given_date} , ${given_pivoted_month} ) = 0 , ${given_measure} , 0 ))
The above Table Calculation will return a column for each store, but the computation is achieved in a single calculation.
Up Next:
Read How to do conditional formatting of color or images within table cells using HTML in Looker?