Tableau Lesson 39 – FIXED / INCLUDE / EXCLUDE | Dataplexa
Section IV — Lesson 39

FIXED, INCLUDE, and EXCLUDE — In Depth

With the three LOD keywords understood individually, this lesson builds the patterns that appear in professional dashboards: customer segmentation, cohort analysis, ratio-to-parent calculations, and the rules that govern how LOD expressions interact with filters and aggregations.

FIXED with Multiple Dimensions

A FIXED expression can declare more than one Dimension, separated by commas. The aggregation then computes at the intersection of all declared Dimensions — just as a view-level aggregation computes at the intersection of all Dimensions currently in the view.

Sales per Customer per Region — two-Dimension FIXED

{ FIXED [Customer Name], [Region] : SUM([Sales]) }

FIXED with no Dimension — grand total on every row

{ FIXED : SUM([Sales]) }

Cohort Analysis — FIXED in Practice

Cohort analysis groups customers by the month they first purchased and then measures their behaviour in subsequent months. It requires two FIXED expressions working together — the acquisition date and the months-since-acquisition offset — both attached to every order row.

Step 1 — Acquisition Month per Customer

{ FIXED [Customer Name] : MIN([Order Date]) }

Step 2 — Months Since Acquisition per Order

DATEDIFF('month',
  { FIXED [Customer Name] : MIN([Order Date]) },
  [Order Date]
)

Cohort Grid — Labelled Mockup

Cohort Retention — Rows: Acquisition Month · Columns: Months Since Acquisition · Values: Active Customers
Cohort Month 0 Month 1 Month 2 Month 3 Month 6
Jan 2022 248 186 154 131 98
Feb 2022 312 241 198 167 122
Mar 2022 289 210 172 140 88
Apr 2022 195 148 119 97 61
Darker blue = more active customers · Fading right = natural churn over months

INCLUDE — Computing at a Finer Granularity Than the View

INCLUDE temporarily adds the Dimension you declare to the current view's Dimensions, computes the aggregation at that finer level, and then lets the outer aggregation summarise those finer results back up to the view level. The key phrase is finer than the view — INCLUDE always drills down, never up.

The most common situation where INCLUDE is needed: you want the average of a group total, not the average of individual rows. These are very different numbers and a plain AVG() cannot distinguish between them without INCLUDE.

Plain AVG([Sales])
Averages every individual order line value. In a view at Category level, this averages all ~9,000 row values and reports one number per Category. It does not know anything about customers.
AVG( { INCLUDE [Customer Name] : SUM([Sales]) } )
First totals Sales per Customer (within each Category). Then averages those per-customer totals at the Category level. This is the true average customer spend — a meaningful business metric.

Average Customer Spend per Category — INCLUDE in practice

AVG( { INCLUDE [Customer Name] : SUM([Sales]) } )

Maximum single-order value per Sub-Category — INCLUDE with MAX

MAX( { INCLUDE [Order ID] : SUM([Sales]) } )

INCLUDE — How the Two-Step Evaluation Works

AVG( { INCLUDE [Customer Name] : SUM([Sales]) } ) — view at Category level
Step 1 — INCLUDE computes
Category Customer SUM(Sales)
Technology Cust A $1,200
Technology Cust B $840
Technology Cust C $3,100
Furniture Cust A $520
Furniture Cust D $2,300
Step 2 — AVG aggregates up
Category AVG Customer Spend
Technology $1,713
Furniture $1,410
Technology: (1200+840+3100)/3 = $1,713
Furniture: (520+2300)/2 = $1,410

INCLUDE vs FIXED — Choosing Between Them

Scenario Use INCLUDE Use FIXED
Filter sensitivity Result should change when a dimension filter is applied Result should stay constant regardless of view filters
Direction Drilling finer than the view — adding a Dimension to the calculation Fixing at an exact level — regardless of the view
Typical pattern AVG( { INCLUDE [fine grain] : AGG } ) — average of group totals at view level { FIXED [grain] : AGG } — stamp a value on every row for a Dimension member
Example Avg customer spend shown per Category — updates when Region filter changes Customer lifetime value attached to every order row — ignores Region filter

Customer Segmentation — FIXED for Bin Assignment

A common segmentation pattern computes a customer-level metric with FIXED and then uses an IF/CASE calculation to assign each customer to a segment. Because the FIXED value is the same on every row for a given customer, the segment label is also consistent across all their rows — making it safe to use as a filter or Color Dimension without double-counting.

Customer Lifetime Segment — combining FIXED with IF logic

IF { FIXED [Customer Name] : SUM([Sales]) } >= 5000 THEN "High Value"
ELSEIF { FIXED [Customer Name] : SUM([Sales]) } >= 1000 THEN "Mid Value"
ELSE "Low Value"
END

Ratio to Parent — EXCLUDE for Share of Category

A ratio-to-parent calculation divides each Sub-Category's Sales by its parent Category's total. EXCLUDE removes Sub-Category from the aggregation to get the Category-level denominator — without leaving the current view or adding a separate table calculation.

Sub-Category Share of Category Sales

SUM([Sales]) / { EXCLUDE [Sub-Category] : SUM([Sales]) }

LOD Expressions in the Filter Order

Understanding where LOD expressions sit in the filter execution order explains nearly every unexpected result when LOD and filters interact.

1
Extract & Data Source Filters — applied first, before anything else
2
Context Filters — FIXED LOD expressions compute after this step
FIXED LOD expressions compute here — after context filters, before dimension filters
3
Dimension Filters — FIXED ignores these. INCLUDE and EXCLUDE respect these.
4
INCLUDE & EXCLUDE LOD expressions compute here — at the same level as dimension filters, so they respect them
5
Table Calculation Filters — applied last, after all aggregation

Nested LOD Expressions

LOD expressions can be nested inside other LOD expressions or inside regular aggregation functions. A nested LOD first computes the inner expression at its declared granularity, then the outer expression aggregates those results at its own level. The cohort months-since-acquisition calculation from earlier is an example — DATEDIFF() wrapping a FIXED expression.

Average Customer Lifetime Value by Region — nested FIXED inside AVG

AVG( { FIXED [Customer Name] : SUM([Sales]) } )
📌 Teacher's Note

The filter order diagram is worth memorising: FIXED computes after context filters but before dimension filters. That single fact explains every LOD debugging scenario you will encounter. If FIXED gives wrong results when a filter is applied, the fix is always to promote that filter to context. The ratio-to-parent EXCLUDE pattern — SUM([Sales]) / { EXCLUDE [Sub-Category] : SUM([Sales]) } — replaces complex Percent of Total table calculation workarounds once you know it exists.

Practice Questions

1. A view shows Region on Rows. Write the LOD expression that returns the average customer lifetime Sales value per Region — not the average order line value.

2. Write the calculated field that returns each Sub-Category's Sales as a share of its parent Category's total Sales — where the denominator changes automatically per Category.

3. Write the LOD expression that returns the overall grand total of Sales on every single row — regardless of Category, Region, or any other Dimension in the view.

Quiz

1. A FIXED expression computing customer lifetime Sales returns the same value when a Region dimension filter is applied and when it is removed. At which point in the filter execution order does FIXED compute, and what is the fix?


2. A cohort analysis grid needs Acquisition Month on Rows and Months Since Acquisition on Columns. Which two calculated fields are required and what does each compute?


3. You want a calculated field showing each Category's Sales as a percentage of the overall grand total — not just of the visible view. Which LOD expression provides the correct grand total denominator?


Next up — Lesson 40: Advanced LOD patterns — set-based analysis, survey data normalisation, and using LOD expressions to solve problems that require multiple levels of aggregation simultaneously.