2. • What is a Table Calc?
• Best Practices
• How to create a Table Calc
• Mathematical functions
• String Functions
• Date Functions
2
Agenda
3. • A way to create columns on the fly
• Based on Looker Expressions
(lexp) rather than LookML
• Anyone can make them
• Always based on the fields in an
existing report
3
Overview
4. • You want to perform a one off
calculation
• You want to do something that
would be really hard in SQL, like
window functions
4
Best Practices
5. • Let’s calculate our total number of
new male and female users per
week starting here
• We will use only basic + operator
and no formatting
• Now say we want to know what
percentage of our new users are
female
• We will reference our previous
table calc and use formatting
• Final product
5
My first table calc
6. Mathematical Functions
• Can be per row (round, rand) or aggregations (sum, max) which mean one result for all
rows
• Let’s use rand which operates per row to create a report which surfaces 5 random order
items to review
• Start here
• Common pitfall: cannot sort on reports that have hit the row limit
• Solution: Increase the limit or filter the results
• Tip: Hide from visualization
• Final product
7. Mathematical Functions Continued
• Let’s use table calcs to take the aggregate of an aggregate
• Say we want to know the average number of items we have delivered in the past 4
weeks
• Start here with the count per week
• Common pitfall: aggregations will only aggregate what is being shown on the report
• Solution: limit the result set or do the calculation in LookML
• Final product
8. • Allows you to manipulate strings
• Similar to functions allowed in SQL
• No regex at the moment
• My favorite is contains
• Let’s check this explore to see which
product names contain the word
‘jean’
• Final product
8
String Functions
9. • You can add and subtract dates!
• Similar to functions allowed in SQL
but dialect agnostic (so nice!)
• Let’s use diff_days to find the time
that it takes for an order item to be
delivered starting from this explore
• Final product
9
Date Functions
10. • Take advantage of autocomplete!
• Cannot filter
• Can sort if not hitting the row limit
• Will be grouped by any dimensions
used in the report
• Check out the docs!
10
Tips and Tricks