Starting in Looker 21.12, you can use Quick Calculations to perform common calculations on numeric fields that are in an Explore's data table without using Looker functions and operators when the Custom Fields Labs feature is enabled, and you have permission to use them.
The
pivot_row
table calculation function groups together all the values of a pivoted row as a list.
How Does It Work?
For example, in the following table, we can use pivot_row()
to write this table calculation:
pivot_row(${product.count})
This will display a list of all the values in each pivot row:
Calculating the Row Total Using
pivot_row
We can then perform calculations on the previous list; for example, we can calculate the row total of this data using the
pivot_row
function:
sum(pivot_row(${product.count}))
This function first grabs the pivot row of
${product.count}
as a list, and then sums that list together. This results in:
The
pivot_row
function can be used to aggregate across any pivoted row. For example, rather than a sum()
, we can also calculate the mean()
of the values in the list, the max()
, the min()
, and so on. This section of the Looker Functions and Operators documentation page lists all the available table calculation functions and operators.
We can also perform more complex calculations across pivot rows with the pivot_row
function, including a percent of total. Read about how to use pivot_row to calculate a percent of total across rows here .