INCLUDE and EXCLUDE LOD expressions

Calculations in Tableau

Maarten Van den Broeck

Content Developer at DataCamp

LOD expressions - recap

LOD expressions: three powerful formulas that allow us to calculate at a different level of detail than the data in the visualization.

  • FIXED: calculating at an exactly specified level of detail.
  • EXCLUDE: calculating at a higher level of detail.
  • INCLUDE: calculating at a lower level of detail.
Calculations in Tableau

INCLUDE LOD syntax

Syntax: { INCLUDE [Dimension 1], [Dimension 2], ... : aggregation expression }

E.g. Syntax example of INCLUDE LOD expression

  • Calculate at a finer level of detail than in the database
  • Re-aggregate and show it at a coarser level of detail in your visualization

White space

Calculation will change if you add/remove dimensions from the view.

Calculations in Tableau

INCLUDE LOD example

Underlying data:

Example dataset, a table with three rows and 4 columns

Avg. Profit: AVG(Profit)

Table with average profit calculation

Avg. Profit per customer:

AVG({INCLUDE [Customer] : SUM(Profit)})

Table with average profit per customer calculation with INCLUDE

Calculations in Tableau

EXCLUDE LOD syntax

Syntax: { EXCLUDE [Dimension 1], [Dimension 2], ... : aggregation expression }

E.g. Syntax example of EXCLUDE LOD expression White space

  • Calculating at a higher level of detail than the one present in the view.
  • Calculation will change if you add/remove dimensions from the view.
Calculations in Tableau

EXCLUDE LOD example

A table with three rows and four columns, including subtotals and various measures

White space Profit (per Product Category): { EXCLUDE [Product Id] : SUM([Profit]) }

Calculations in Tableau

FIXED vs. INCLUDE vs. EXCLUDE?

FIXED

  • Calculating at a specified level of detail
  • It will give the same result regardless of the dimensions visualization

INCLUDE

  • Calculating at a lower level of detail
  • Calculation result will change when dimensions are added or removed from the canvas

EXCLUDE

  • Calculating at a higher level of detail
  • Calculation result will change when dimensions are added or removed from the canvas
Calculations in Tableau

Order of operations

Tableau executes filters in a specified order:

Schematics of Tableau's order of operations

1 https://help.tableau.com/current/pro/desktop/en-us/order_of_operations.htm
Calculations in Tableau

Let's practice!

Calculations in Tableau

Preparing Video For Download...