Introduction to calculations

Calculations in Tableau

Agata Bak-Geerinck

Senior Data Analyst, Telenet

Why do calculations?

Calculations allow you to create new data from data that already exists in your data source and perform computations on your data

Typical use-cases:

  • Measure missing in original dataset:

    • e.g. Sales and Costs but no Profit measure
  • Transforming existing data:

    • e.g extracting First name from First and Last name
  • Categorizing the data:
    • e.g. grouping Age into "Kids", "Teens", "Adults", based on age thresholds
  • ...
Calculations in Tableau

Types of calculations in Tableau

There are four main types of calculations:

Basic calculations:

  • Row-level calculations
  • Aggregate calculations

Advanced calculations:

  • Level of Detail expressions
  • Table Calculations

A snapshot of a spreadhseet

Calculations in Tableau

Row-level calculations vs. aggregations

  • Row-level calculations

    • Performed on each individual row
    • e.g. End Date-Start Date

A table with start and end date and a calculation of a difference between a start and an end date

  • Aggregate calculations e.g. SUM(), AVG()
    • Performed on set of records defined by dimensions in the view
    • e.g Sum of Profit = SUM(Sales)- SUM(Cost)
    • Recalculated per dimension in the view

A table presenting Sum of Profit per Region

Calculations in Tableau

Most common calculation errors

  • Tableau has a built-in calculation validity check! Snipet of Tableau's "Calculation is valid" message
  • Do NOT mix up row-level and aggregate calculations:

    Example of erroneous calculation involving mixing aggregate and non-aggregate values

    • Use only row-level or aggregation calculation
  • Do NOT apply calculations on incompatible data types:

Example of erroneous calculation involving mathematical operations on incompatible data types

  • Watch out for syntax errors:
    • Missing syntax elements, e.g. ELSEIF or END in an IF() statement
    • Missing an identifier, operator, comma, or parenthesis
    • Using incorrect bracket type {}, [], ()
Calculations in Tableau

Most common logical errors

Tableau validity check does NOT eliminate all errors!

Typical logical / mathematical errors:

  • Applying mathematical operations in the wrong order
  • Incorrect or missing brackets in AND and OR statements
  • Wrong application of conditions in IF and CASE statements
  • Summing the non-summable values, e.g. Customer IDs
  • Averaging the average
  • ...

Final analytical responsibility lies with you!

Calculations in Tableau

The dataset - Fitbit usage

Visual representing a smart watch and various types of activities which can be tracked, such as sleep, heart rate and exercise

Calculations in Tableau

Let's practice!

Calculations in Tableau

Preparing Video For Download...