This lesson on INCLUDE & EXCLUDE LOD Expressions is hands-on and example-driven. You will master Level of Detail (LOD) expressions in Tableau to compute values at granularities independent of your visualization's layout. You will be able to construct FIXED, INCLUDE, and EXCLUDE calculations to zoom into granular metrics, zoom out for category totals, and avoid common aggregation mismatch errors.
What You'll Be Able To Do
- Construct FIXED, INCLUDE, and EXCLUDE expressions using correct curly brace syntax.
- Compute category-level aggregations in fine-grained views that bypass standard dimension filters using FIXED.
- Calculate fine-grained sub-aggregations like average product sales within high-level category views using INCLUDE.
- Eliminate specific view dimensions like Region from calculations while keeping them in the visualization using EXCLUDE.
- Resolve the 'cannot mix aggregate and non-aggregate arguments' error by wrapping whole-dataset totals in table-scoped LODs.
Detailed Concept Walkthrough
1. LOD Architecture and Syntax Structure
LOD expressions act like a camera lens that adjusts the analytical zoom level independently of the dimensions placed on rows, columns, or marks cards.
- Syntax Rule: Every LOD expression is wrapped in outer curly braces
{ }, starts with the scoping keyword (FIXED,INCLUDE, orEXCLUDE), followed by zero or more comma-separated grouping dimensions, a colon:, and an aggregate calculation. - Under the Hood: Tableau interprets the colon as the boundary separating the target level of dimensionality (grouping set) from the mathematical operation (
SUM,AVG,COUNT). - Execution Flow: When processed, Tableau computes the aggregation grouped by the explicitly defined dimension set before merging the resulting scalar or row-level values back into the primary visualization pipeline.
// Standard LOD calculation template
{
FIXED [Category], [Region] : SUM([Sales])
}
Key Takeaway: All LOD expressions share the uniform syntax:
{ [TYPE] [Dimension1], [Dimension2] : AGG([Field]) }.
2. FIXED Expressions and Dimension Independence
FIXED computes values exclusively at the specified dimension level, locking the computation and ignoring both unlisted view dimensions and standard dimension filters.
- Mechanism: When specifying
FIXED [Category] : SUM([Sales]), Tableau aggregates sales solely across each Category, returning identical values across every Sub-Category mark within that Category. - Filter Behavior: Standard dimension filters (such as excluding a specific Sub-Category or Product) do not reduce or alter the value produced by a FIXED expression.
- Multi-Dimensional Grouping: Adding multiple dimensions separated by commas (e.g.,
[Category], [Region]) forces Tableau to compute independent totals for each unique dimension combination regardless of chart detail.
// Locks Sales total at the Category level
// Bypasses Sub-Category filters in the sheet
{
FIXED [Category] : SUM([Sales])
}
Key Takeaway: FIXED establishes an absolute calculation boundary that operates independently of chart dimensions and standard filters.
3. INCLUDE Expressions for Finer Granularity
INCLUDE forces Tableau to consider a dimension not present in the visualization frame, calculating metrics at a more detailed level before aggregating them into the view.
- Mechanism: In a high-level view (e.g., Category Sales),
INCLUDE [Product Name] : AVG([Sales])computes the average sales per individual product first, then aggregates those product averages to the category level. - Under the Hood: An INCLUDE calculation respects all dimensions and filters in the sheet; if a user filters out individual products, the recalculated grand total changes accordingly.
- View Granularity Alignment: When the view is expanded down to the row level (e.g., adding
[Order ID]), the INCLUDE calculation naturally converges to match the standard measure aggregation.
// Calculates average product sales within each category in the view
{
INCLUDE [Product Name] : AVG([Sales])
}
Key Takeaway: INCLUDE adds hidden detail to higher-level views while remaining fully responsive to the chart's active filters and structure.
4. EXCLUDE Expressions for Broader Context
EXCLUDE removes specific dimensions that exist in the chart frame from the calculation, allowing high-level totals to display alongside detailed marks.
- Mechanism: When a chart displays
[Category]and[Region], writingEXCLUDE [Region] : SUM([Sales])strips the region dimension from the calculation, outputting the overall category total across all regional marks. - Filter Responsiveness: Unlike FIXED, EXCLUDE evaluates after sheet filters are applied, meaning filtering out a region dynamically recalculates the category total.
- Visual Application: This enables direct comparison between a specific segment (Region) and its broader grouping (Category) within the exact same visual frame.
// Removes Region from computation to display overall Category Sales
{
EXCLUDE [Region] : SUM([Sales])
}
Key Takeaway: EXCLUDE subtracts visual dimensions from the calculation while maintaining full sensitivity to chart filters.
5. Table-Scoped LODs and Aggregation Mixing
Omitting dimension declarations entirely creates a table-scoped LOD that computes across the entire dataset, solving aggregation mismatch errors in complex ratios.
- Mechanism: Writing
{ SUM([Sales]) }without a scope keyword or dimension calculates the grand total of sales across the entire dataset. - Syntax Rule: Combining an LOD calculated field like
{ FIXED [Category] : SUM([Sales]) }with a bareSUM([Sales])produces a 'Cannot mix aggregate and non-aggregate arguments' error. - Resolution: Wrapping the denominator in
{ SUM([Sales]) }provides a uniform scalar value across all rows, enabling seamless percent-of-total calculations without table calculation dependencies.
// Category percent of total sales calculation
// Resolves aggregate / non-aggregate mixing errors
{
FIXED [Category] : SUM([Sales])
}
/
{
SUM([Sales])
}
Key Takeaway: An empty dimension LOD (
{ SUM([Field]) }) computes dataset-wide totals and resolves mixed-aggregation syntax errors.
Topics Covered in INCLUDE & EXCLUDE LOD Expressions
- LOD Mental Model (0:00 - 0:45) — Introduces the camera lens analogy for zooming into details or zooming out for bigger-picture totals.
- Three LOD Types & Syntax (0:45 - 1:26) — Outlines FIXED, INCLUDE, and EXCLUDE behaviors and details the mandatory curly brace and colon syntax.
- Single & Multi-Dimension FIXED (1:26 - 2:35) — Demonstrates category and category-region sales calculations that remain unaffected by sub-category filters.
- INCLUDE LOD Mechanics (2:35 - 3:45) — Calculates average sales per product inside a category view and shows how sheet filters affect the results.
- EXCLUDE LOD Implementation (3:45 - 4:40) — Removes the region dimension to display category totals and contrasts its filter sensitivity against FIXED.
- Percent of Total & Error Fix (4:40 - 5:50) — Resolves mixed-aggregation errors using a table-scoped LOD to calculate category percent of total sales.
Reference Cheat Sheet
-
{ FIXED [Dim] : AGG([Field]) }— Computes aggregate at exact dimension level, ignoring chart filters{ FIXED [Category] : SUM([Sales]) } -
{ FIXED [Dim1], [Dim2] : AGG([Field]) }— Calculates aggregate across multiple fixed dimensions simultaneously{ FIXED [Category], [Region] : SUM([Sales]) } -
{ INCLUDE [Dim] : AGG([Field]) }— Adds dimension to calculation while respecting chart filters{ INCLUDE [Product Name] : AVG([Sales]) } -
{ EXCLUDE [Dim] : AGG([Field]) }— Removes chart dimension from calculation while respecting filters{ EXCLUDE [Region] : SUM([Sales]) } -
{ AGG([Field]) }— Computes aggregate across entire dataset ignoring all dimensions{ SUM([Sales]) }
Comparison Table
| Feature / LOD Type | FIXED | INCLUDE | EXCLUDE |
|---|---|---|---|
| Dimension Scope | Explicitly defined only | View dimensions plus added | View dimensions minus excluded |
| Filter Sensitivity | Ignores standard dimension filters | Respects sheet filters | Respects sheet filters |
| Primary Use Case | Independent totals & baselines | Finer detail without splitting marks | Broader totals across existing marks |
Common Pitfalls
- Mistake: Expecting FIXED LODs to update when users adjust standard view filters. Avoid: Use EXCLUDE or context filters if the calculation must reflect sheet-level filtering.
- Mistake: Dividing an LOD measure directly by SUM(Field) and triggering aggregate mismatch errors. Avoid: Enclose the total denominator in a table-scoped LOD like { SUM(Field) }.
- Mistake: Relying on Quick Table Calculations to compute category-level percentages in sub-category views. Avoid: Build an explicit LOD calculation to lock the numerator aggregation to Category.
FAQs
- Why does FIXED Category Sales show the same number when a Sub-Category is filtered out? FIXED expressions are evaluated before standard dimension filters in Tableau's order of operations, rendering them immune to chart-level filter exclusions.
- What is the mathematical difference between AVG(Sales) and an INCLUDE AVG(Sales) LOD? Standard AVG(Sales) averages every underlying raw transaction row, whereas INCLUDE averages the sales per specified dimension first and then averages those group results.
- When should I use EXCLUDE instead of FIXED? Use EXCLUDE when you want to remove a specific dimension from the calculation while ensuring the computed total still reacts dynamically to other active sheet filters.