Tableau
Intermediate 16 min read Tableau

Calculations and LOD Expressions

Compute anywhere, not just at the row or view grain

Calculated fields extend your data in the view, and Level of Detail (LOD) expressions compute across any grain — fixed, include and exclude. LODs are the superpower for ratios and percentages.

calculated fieldLODFIXEDINCLUDEEXCLUDEaggregationdawn
Prerequisites: Data Connections
Before we start

What you will learn

  • Write calculated fields that drive measures
  • Explain FIXED vs INCLUDE vs EXCLUDE
  • Use LODs for share-of-total and per-customer numbers
Introduction

What is this?

A calculated field is a formula evaluated in the data, and a LOD expression overrides the grain: FIXED computes once per a chosen set of dimensions no matter what the view filters, INCLUDE asks Tableau to keep a dimension in the calculation even when the view drops it, and EXCLUDE removes a dimension the view would otherwise use. Together they make per-customer, per-category and window computations possible at any grain.

Motivation

Why do you need it?

  • Row-grain formulas can't answer 'share of total' — the divisor needs a different grain.
  • LODs replace a whole family of table calcs and SQL subqueries inside the workbook.
  • Correct percentages and rankings are the most-requested KPI in Tableau.
  • Interviews probe LOD specifically to separate scripted workbooks from designed ones.
Think about it

Mental model

Imagine

Zooming a camera

Think of

LOD expressions

A FIXED lens locks a zoom level regardless of how the page is cropped (view filters). INCLUDE always keeps a subject in frame even if the crop drops it. EXCLUDE keeps the subject out of focus no matter the crop. Your thumb (the divide) needs a second, intentionally-locked frame.

Mechanics

How it works

  • A plain field computes at the view grain affected by every filter on any dimension.
  • FIXED([dim]): SUM(amount) ignores view filters on other dimensions, computed once per [dim].
  • INCLUDE([dim]): keeps [dim] in the calculation even when the view splits differently.
  • EXCLUDE([dim]): drops [dim] even when the view shows it.
  • Grouping LODs together like { FIXED [Customer]: SUM(x) } lets you reuse one computation in many measures.

How grains differ between plain, FIXED and INCLUDE.

Rows in view
Plain SUM
FIXED [Customer]
INCLUDE [Month]
Percent of total
Hands-on

Examples

Share of revenue per region with FIXED

Share of revenue per region with FIXED
Total Revenue = SUM([Revenue])
Revenue Share =
[Total Revenue] /
{ FIXED : SUM([Revenue]) }

The numerator IS the current view grain; the denominator uses `{ FIXED : }` (no dimension list) to lock to the whole dataset regardless of filters, so the share stays true against total revenue while filters zoom the view.

Real world

In production

  • A retail team computes customer lifetime spend with { FIXED [Customer]: SUM(...) } and ranks customers regardless of which month filter is active.
  • A marketing analyst builds 'share of market' where the denominator uses FIXED to ignore the company strip filter.
  • A finance vault computes month-over-month change with INCLUDE to keep each calendar month in the moving comparison.
Guidelines

Best practices

  • Store the LOD into a reusable calculated field once, then reference it from measures.
  • Put FIXED on stable dimensions (customer, product) and avoid date-dimension FIXED unless intended.
  • Name LODs with the grain in the name: 'CustomerLTV (FIXED customer)'.
  • Test an LOD in a simple table before wiring it into a complex dashboard.
Watch out

Common mistakes

  • Using plain SUM for a share numerator that already changed grain.
  • FIXED with a huge dimension cardinality, breaking ties in ranking.
  • Applying INCLUDE where a simple FIXED suffices — INCLUDE multiplies the row budget.
  • Forgetting that filters may exclude reference rows the LOD needs.
Root cause analysis

Common issues

Error
A FIXED LOD still changes when a filter is applied
Root cause

A context filter excludes rows before the LOD runs

Fix

Move the filter into the LOD's own condition or remove it from context.

Error
INCLUDE explodes cardinality for a dashboard
Root cause

The LOD re-aggregates across a wide dimension per view row

Fix

Switch to FIXED/precompute the field in the data source.

Error
Percent of total exceeds 100
Root cause

The divisor and numerator computed at different grains or double-counted

Fix

Use matching FIXED grains for both parts of the quotient.

When things break

Debugging tips

  • Duplicate the LOD in a plain table at the suspected grain to inspect its outputs.
  • Draw the view before/after to see when the LOD stops following a filter.
  • Compare { FIXED } totals to a hand-computed aggregate in Excel for the same subset.
  • Look at tooltips showing the computed row count to spot cardinality blowups.
Interviews

Interview checkpoint

Practice

Hands-on lab

LOD in Action
30 min · intermediate
In progress
Objectives
  • Create FIXED customer totals
  • Compute a denominator that ignores filters
  • Use INCLUDE for per-month logic
  • Build a correct share-of-total measure

LOD in Action

30 min · intermediate

0/5 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

Which LOD computes one value per customer regardless of the region filter?

2

A LOD expression changes when the view grain changes.

Go deeper

Official documentation