2. • What is a Table Calc?
• Conditional statements
• Offset functions
• Pivot functions
• Statistical functions
• Questions
2
Agenda
3. • An easy way for everyone to
create their own calculations on
the fly without the help of an
analyst!
• Based on Looker Expressions
(LExp) rather than LookML
• Can only reference fields included
in the report
• Advanced functions include
looking at row-over-row data,
pivot data, conditional statements,
etc.
3
Overview
4. We are an Ecommerce company
using a data set that includes
information on Order Items, Users,
Products, Orders and Inventory
Items
*All examples are on learn.looker.com
*Slides will be available after presentation
4
Let’s dive in!
5. Conditional Statements
What this is helpful for:
• Bucketing data
• Conditional calculations (sum, mean, percent
change, based on a condition)
Let’s give it a try!
• We have a report that includes user age and order
count. Using this explore, how can we bucket users
by age and take the sum per bucket?
Additional Examples
5
if(${users.age} <= 50, "<= 50", null)
Nested if functions
if(${users.age} <= 50, "<= 50",
if(${users.age} > 50 AND ${users.age} < 75, "Between 50 and 75",
null))
if(${users.age} <= 50, "<= 50",
if(${users.age} > 50 AND ${users.age} < 75, "Between 50 and 75",
“>= 75”))
6. Offset Functions
What this is helpful for:
• Row-over-row comparisons
• Rolling average
• Custom running total
Let’s give it a try!
• We have a report that includes order items created year
and the count of order items. Using this explore, how can
we compare this year’s order items count to last year’s?
• Using the same report, how can we take the rolling
average from the past 3 years?
Additional Examples
6
mean(
offset_list(${order_items.count}, 0, max(row()) - row()
+ 1))
Rolling Average Using offset_list
offset_list(${order_items.count}, 0, max(row()) - row() +
1)
7. Pivot Functions
What this is helpful for:
• Side-by-side comparisons
• Grab data from specific pivot column
• Aggregate across rows
Let’s give it a try!
• We have a report that displays created year, user
age and order items count.
• Using this explore, how can we display percent of
total by year and only display data for this year?
Additional Examples
7
pivot_index(${order_items.count}, 4)
Pivot index
VS
Pivot where
pivot_where(${order_items.created_year} =
date(2015,01,01), ${order_items.count})
8. Statistical Functions
Let’s give it a try!
• We have a report that includes created month and
user age. Using this explore, how can we find the
most frequently occurring value for users age?
• We have a report that includes user state and
product total cost per state. Using this explore,
how can we find the percent rank for our total cost
values?
*All functions can be found in the Looker Functions &
Operators doc.
8
mode(${users.age})
percent_rank(${products.total_cost},${products.total_cost
})
Mode of User Age
Percent Rank of Total Cost
9. 9
Some other cool functions...
large small skew kurtosis product geomean mode count_distinct chisq_test correl
covar_samp covar_pop slope intercept t_test binom_dist binom_inv norm_dist norm_inv
norm_s_dist norm_s_inv t_dist t_inv confidence_norm confidence_t beta_dist beta_inv gamma_dist
gamma_inv chisq_dist chisq_inv f_dist f_inv hypgoem_dist negbinom_dist poisson_dist weibull_dist
expon_dist rank_avg rank percent_rank z_test acos asin atan cos sin tan degrees
radians fact combin pi multinomial index match lookup