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.
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
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.
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.
Mental model
Zooming a camera
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.
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.
Examples
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.
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.
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.
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.
Common issues
A FIXED LOD still changes when a filter is appliedA context filter excludes rows before the LOD runs
Move the filter into the LOD's own condition or remove it from context.
INCLUDE explodes cardinality for a dashboardThe LOD re-aggregates across a wide dimension per view row
Switch to FIXED/precompute the field in the data source.
Percent of total exceeds 100The divisor and numerator computed at different grains or double-counted
Use matching FIXED grains for both parts of the quotient.
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.
Interview checkpoint
Hands-on lab
- 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
Quick quiz
Which LOD computes one value per customer regardless of the region filter?
A LOD expression changes when the view grain changes.