TABLEAU • CALCULATIONS AND METRICS

INCLUDE/EXCLUDE LOD — Use INCLUDE/EXCLUDE LOD to control granularity

Master Level of Detail expressions to compute aggregations at precisely the granularity you need, independent of the view.

Historical Context & Motivation

Before Tableau introduced Level of Detail (LOD) expressions in version 9.0, analysts faced a persistent problem: the granularity of every calculation was dictated solely by the dimensions present in the visualization. If your view displayed data at the product level, every aggregation—SUM, AVG, COUNT—was computed at the product level, with no straightforward way to reference a different grain. Workarounds existed—table calculations, data blending, custom SQL—but each introduced complexity, performance overhead, or fragility that made dashboard maintenance burdensome. For anyone accustomed to writing GROUP BY clauses in SQL, this limitation felt particularly constraining, because SQL lets you freely control the grouping level of any subquery or window function. LOD expressions were Tableau's answer to that gap, and the INCLUDE and EXCLUDE keywords gave analysts declarative control over which dimensions participate in an aggregation, independent of the view.

2003
Tableau Founded
Tableau emerges from Stanford research on VizQL, a visual query language that translates drag-and-drop actions into database queries. Aggregation granularity is always coupled to the dimensions on the shelf.
2010
Table Calculations Mature
Tableau 6 expands table calculations—WINDOW_SUM, RUNNING_TOTAL, LOOKUP—offering post-aggregation transformations. However, these operate on the result set, not the underlying data source, limiting their flexibility for cross-grain aggregation.
2015
LOD Expressions Introduced (v9.0)
Tableau 9.0 introduces FIXED, INCLUDE, and EXCLUDE LOD expressions. For the first time, analysts can declaratively specify aggregation granularity at the data-source level, independent of the visualization's dimension shelf.
2018
LOD + Sets & Parameters
Subsequent releases improve LOD expression compatibility with sets, parameters, and data source filters. Performance optimizations reduce the query overhead of nested LOD calculations.
2023
Modern Analytics Ecosystem
LOD expressions are now foundational to advanced Tableau workflows, appearing in cohort analysis, customer segmentation, and KPI dashboards. They remain one of Tableau's most powerful—and most misunderstood—features.

The central question that INCLUDE and EXCLUDE LOD expressions address is deceptively simple: how do you compute a metric at a different level of granularity than what is currently displayed, and then seamlessly blend it back into the view? Understanding the answer requires a precise mental model of how Tableau's query pipeline processes dimensions, aggregations, and filters—and that is exactly what this lesson develops.

Core Principles & Definitions

To wield INCLUDE and EXCLUDE LOD expressions effectively, you need to internalize a few foundational concepts about how Tableau constructs queries. Every visualization in Tableau implicitly defines a view-level granularity—the set of dimensions currently on the Rows, Columns, Color, Size, Detail, and Tooltip shelves. This view-level granularity determines the GROUP BY clause of the underlying query. LOD expressions let you override that implicit grouping by explicitly adding or removing dimensions from the aggregation context.

1

View-Level Granularity

The implicit grain of aggregation determined by dimensions on Tableau's shelves. Equivalent to the GROUP BY clause in the generated SQL. Every standard aggregation (SUM, AVG, etc.) operates at this level.
2

INCLUDE LOD

Adds one or more dimensions to the view-level grain, computing the aggregation at a finer level than the view. Syntax: { INCLUDE [Dim] : AGG(Measure) }. The result is then re-aggregated to the view level.
3

EXCLUDE LOD

Removes one or more dimensions from the view-level grain, computing the aggregation at a coarser level than the view. Syntax: { EXCLUDE [Dim] : AGG(Measure) }. The coarser value is then replicated across view rows.
4

FIXED LOD (Reference)

Defines an absolute grain, ignoring the view's dimensions entirely. Unlike INCLUDE/EXCLUDE, FIXED does not adapt when you add or remove dimensions from the view. It operates independently of the view-level context.
5

Re-Aggregation

When an INCLUDE LOD produces values at a finer grain than the view, Tableau must re-aggregate those values (e.g., AVG, MIN, MAX) to display them. This wrapping aggregation is key to understanding INCLUDE behavior.
KEY TAKEAWAY
Think of the view's dimensions as a camera zoom level. INCLUDE is like zooming in—you see finer detail before aggregating back. EXCLUDE is like zooming out—you blur away a dimension to see a broader picture. In SQL terms, INCLUDE adds columns to GROUP BY; EXCLUDE removes columns from GROUP BY. Both are relative to the current view, which makes them adaptive as you evolve your dashboard.

Visual Explanation

The following diagram illustrates how INCLUDE and EXCLUDE modify the aggregation grain relative to the view. The center column represents the view-level granularity—the dimensions currently on the shelves. INCLUDE shifts the computation to a finer grain (more dimensions), while EXCLUDE shifts it to a coarser grain (fewer dimensions). After the LOD calculation runs at its specified grain, the result is mapped back to the view through re-aggregation or replication.

The view-level grain (center, purple border) represents the current dimensions on Tableau shelves. INCLUDE (left) adds a dimension, creating a finer aggregation that must be re-aggregated to display. EXCLUDE (right) removes a dimension, creating a coarser aggregation whose values are replicated across view rows.

Notice the critical distinction in the lower boxes. When INCLUDE computes at a finer grain, there are more intermediate rows than the view requires, so Tableau must wrap the LOD result in an outer aggregation—typically AVG(), MIN(), or MAX()—to collapse the extra rows back to the view level. Conversely, when EXCLUDE computes at a coarser grain, there are fewer intermediate rows, so the coarser result is simply replicated (broadcast) to each row at the view grain. This behavior directly parallels how SQL window functions replicate partition-level aggregates across row-level results.

How INCLUDE and EXCLUDE Generate Queries

Understanding the SQL that Tableau generates from LOD expressions demystifies their behavior. Consider a view with [Region] and [Category] on the shelves. The view-level grain is GROUP BY Region, Category. An INCLUDE expression adds a dimension to that GROUP BY, while an EXCLUDE expression removes one. Tableau materializes the LOD computation as a subquery or common table expression (CTE) and then joins it back to the main query.

INCLUDE SYNTAX
{ INCLUDE [Dimension] : AGG([Measure]) }
Effective grain = View dimensions ∪ {Dimension}. Tableau adds [Dimension] to the GROUP BY. The result is finer than the view, so an outer aggregation (e.g., AVG) is required when displayed.
EXCLUDE SYNTAX
{ EXCLUDE [Dimension] : AGG([Measure]) }
Effective grain = View dimensions \ {Dimension}. Tableau removes [Dimension] from the GROUP BY. The result is coarser than the view, so each coarser value is replicated across matching view rows.

Generated SQL Analogy

For a view with dimensions [Region] and [Category], an INCLUDE expression like { INCLUDE [Product] : SUM([Sales]) } generates a subquery equivalent to:

INCLUDE SQL EQUIVALENT
SELECT Region, Category, Product, SUM(Sales) AS lod_sales FROM data GROUP BY Region, Category, Product
This finer-grain result is then joined back to the main query. To display on the view (which groups by Region, Category only), Tableau wraps it: AVG(lod_sales) or whichever outer aggregation you specify.
EXCLUDE SQL EQUIVALENT
SELECT Region, SUM(Sales) AS lod_sales FROM data GROUP BY Region
For { EXCLUDE [Category] : SUM([Sales]) }, Tableau removes [Category] from the GROUP BY. The coarser Region-level total is then replicated to every (Region, Category) row in the view—similar to a SQL window function SUM(Sales) OVER (PARTITION BY Region).
⚠️ Filter Pipeline Note
INCLUDE and EXCLUDE LOD expressions are computed after dimension filters but before context filters (unless you promote a filter to context). This is different from FIXED LOD, which runs before dimension filters. This pipeline order is crucial for debugging unexpected results.

Detailed Breakdown: When to Use INCLUDE vs EXCLUDE

Choosing between INCLUDE and EXCLUDE depends on whether you need to drill deeper than the view or pull back to a broader perspective. In practice, the choice often maps to a specific analytical pattern: INCLUDE is ideal when you need per-entity metrics before summarizing (e.g., average order size per customer, then averaged across regions), while EXCLUDE shines when you want each row to reference a parent-level total (e.g., category sales as a share of regional total). The following diagram maps common analytical scenarios to the appropriate LOD type.

Decision flowchart for selecting LOD type. If the desired grain is relative to the view and finer, use INCLUDE. If relative and coarser, use EXCLUDE. If the grain should be absolute (independent of the view), use FIXED.
Common analytical scenarios mapped to INCLUDE/EXCLUDE LOD patterns
ScenarioLOD TypeExpression ExampleOuter Aggregation
Average order value per customer, displayed per regionINCLUDE{ INCLUDE [Customer ID] : SUM([Sales]) }AVG(...)
Each sub-category's sales as a % of its category totalEXCLUDESUM([Sales]) / { EXCLUDE [Sub-Category] : SUM([Sales]) }Not needed (result is at view grain)
Count distinct products per category, view at region levelINCLUDE{ INCLUDE [Category] : COUNTD([Product]) }SUM(...)
Deviation of each month's sales from yearly averageEXCLUDESUM([Sales]) - { EXCLUDE [Month] : AVG([Sales]) }Not needed

Worked Example: Customer-Level Metrics in a Regional View

Suppose you have a Superstore-style dataset and a bar chart showing SUM([Sales]) per [Region]. Your goal is two-fold: (1) compute the average sales per customer in each region using INCLUDE, and (2) compute the percentage of total sales each region represents using EXCLUDE.

Part A — INCLUDE: Average Sales per Customer by Region
1
Step 1 — Identify the View GrainThe view has [Region] on Rows and SUM([Sales]) on Columns. The view grain is Region alone.
2
Step 2 — Define the INCLUDE LOD ExpressionWe want per-customer sales, which is finer than per-region. We create a calculated field: { INCLUDE [Customer ID] : SUM([Sales]) }. This tells Tableau to compute SUM(Sales) grouped by Region, Customer ID (the view dims plus the included dim).
Effective grain: GROUP BY Region, Customer ID
3
Step 3 — Apply the Outer AggregationSince the LOD result has one row per (Region, Customer ID) but the view only shows one row per Region, we must re-aggregate. Drag the LOD field to the view and select AVG as the aggregation. The pill reads AVG({ INCLUDE [Customer ID] : SUM([Sales]) }).
East: $1,245 avg per customer · West: $1,098 · Central: $967 · South: $1,102 (illustrative values)
4
Step 4 — InterpretThe result tells us the average total spending per customer within each region—a metric that would be impossible to compute with a simple AVG([Sales]) (which averages across individual rows/transactions, not customers). The INCLUDE keyword injected the per-customer grain, and the outer AVG collapsed it to the per-region view.
Part B — EXCLUDE: Percentage of Total Sales per Region
1
Step 1 — Identify What to ExcludeTo compute the overall total sales (ignoring Region), we exclude the only view dimension: { EXCLUDE [Region] : SUM([Sales]) }. With Region removed, the effective grain is the entire dataset—one grand total.
Effective grain: entire table (no GROUP BY)
2
Step 2 — Build the Percentage CalculationCreate a calculated field: SUM([Sales]) / { EXCLUDE [Region] : SUM([Sales]) }. The numerator is the region-level total (view grain), and the denominator is the grand total (coarser grain, replicated to each region row).
3
Step 3 — Format and VerifyFormat the result as a percentage. Each region now shows its share of total sales. Because the EXCLUDE expression adapts to the view, if you later add [Category] to the view, the denominator automatically becomes the total excluding Region but including Category—exactly what you'd want for a per-category share.
East: 29.5% · West: 31.6% · Central: 21.8% · South: 17.1% (illustrative)

Strengths, Limitations & Comparisons

Comparison of INCLUDE, EXCLUDE, and FIXED LOD expressions
CharacteristicINCLUDE LODEXCLUDE LODFIXED LOD
Grain relative to viewFiner (adds dimensions)Coarser (removes dimensions)Independent (absolute)
AdaptabilityAdapts when view dims changeAdapts when view dims changeDoes NOT adapt
Filter pipeline positionAfter dimension filtersAfter dimension filtersBefore dimension filters
Requires outer aggregationYes (AVG, MIN, MAX, etc.)No (value replicated; aggregation is ATTR-like)Depends on context
PerformanceCan be expensive with high-cardinality dimsGenerally efficient (fewer groups)Varies; often most efficient for simple cases
Typical use casePer-entity metrics rolled up to the viewPercent-of-parent, benchmarks, deviationsCohort assignment, date-based bucketing

Strengths of INCLUDE/EXCLUDE

  • View-adaptive: Both INCLUDE and EXCLUDE automatically adjust their effective grain when you add or remove dimensions from the view. This makes dashboards more maintainable than FIXED-based approaches for view-relative calculations.
  • Filter-respecting: Because they sit after dimension filters in the pipeline, INCLUDE and EXCLUDE respect the user's filter selections—a behavior that analysts usually expect.
  • Composable: You can nest LOD expressions inside other calculations, use them in IF statements, or combine INCLUDE and EXCLUDE results in a single formula.

Limitations and Pitfalls

  • Outer aggregation confusion: INCLUDE results must be wrapped in an outer aggregation. Forgetting this—or using the wrong one—is the most common source of errors. AVG, MIN, and MAX produce very different results.
  • Performance with high cardinality: INCLUDE on a high-cardinality dimension (e.g., Customer ID with millions of distinct values) forces Tableau to compute a much larger intermediate result set, which can degrade query performance.
  • EXCLUDE on the last dimension: If you EXCLUDE the only dimension in the view, the grain becomes the entire dataset. This is valid but can be confusing to interpret.
KEY TAKEAWAY
Think of INCLUDE and EXCLUDE like SQL's GROUP BY modifications scoped to a single calculated field. INCLUDE is analogous to a correlated subquery that joins on all view dimensions plus extra ones; EXCLUDE is analogous to a PARTITION BY in a window function where you've deliberately omitted a column. The key advantage over FIXED is adaptability: as the dashboard evolves, these expressions evolve with it.

Connection to Advanced LOD Patterns

INCLUDE and EXCLUDE LOD expressions form the foundation for several advanced analytical patterns in Tableau. Once you have mastered the basic mechanics, you can compose these expressions to handle complex, multi-grain calculations that would otherwise require custom SQL or data model changes. The following table contrasts basic usage with advanced patterns that build on the same principles.

Basic vs. advanced LOD patterns
Basic PatternAdvanced ExtensionDescription
{ INCLUDE [Cust] : SUM(Sales) }Nested LOD: INCLUDE inside FIXEDCompute per-customer sales first, then fix at a cohort level. E.g., { FIXED [Cohort] : AVG({ INCLUDE [Cust] : SUM(Sales) }) }
{ EXCLUDE [Month] : SUM(Sales) }Year-over-year difference with EXCLUDEExclude the month dimension to get an annual total, then compute each month's deviation from the yearly average—a dynamic variance analysis.
Simple percent-of-totalMulti-level percent-of-parentChain EXCLUDE expressions at different levels: exclude Sub-Category for category share, exclude Category for segment share. Each provides a different hierarchical benchmark.
Customer order count (INCLUDE)Frequency binningUse INCLUDE to compute order frequency per customer, then bin the result into "1 order", "2–5 orders", "6+ orders" groups for a histogram at the view level.

As you move toward more sophisticated Tableau development—building parameter-driven dashboards, implementing row-level security, or designing reusable calculated fields—the ability to reason about grain management becomes indispensable. LOD expressions are, at their core, a way to declaratively manage grain in a visual analytics environment. This concept maps directly to dimensional modeling principles (Kimball methodology), where fact tables exist at specific grains and bridge tables mediate between grains. If you continue into data engineering or analytics engineering (e.g., dbt, LookML), you will encounter the same grain-management challenges at the modeling layer, and the mental model you build here transfers directly.

🔮 Looking Ahead
Tableau's newer features—Relationships (introduced in 2020.2) and multi-fact data models—interact with LOD expressions in nuanced ways. When working with relationships, LOD calculations respect the level of detail defined by the relationship's join type, which can produce unexpected results if you're not deliberate about which tables contribute to the grain. Mastering INCLUDE/EXCLUDE now provides the conceptual foundation for navigating these newer paradigms.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain in your own words why an INCLUDE LOD expression requires an outer aggregation (e.g., AVG, MAX) when displayed in a view, while an EXCLUDE LOD expression does not. Reference the concept of grain mismatch in your answer.
PROBLEM 2BASIC CALCULATION
You have a view showing [Category] on Rows and SUM([Profit]) on Columns. Write an INCLUDE LOD expression that computes the total profit per customer within each category, and then the correct pill expression to display the average of those customer-level profits.
PROBLEM 3INTERMEDIATE
Your view shows [Region] and [Sub-Category] on Rows with SUM([Sales]) on Columns. Write an EXCLUDE LOD expression to compute each sub-category's sales as a percentage of its region's total sales. Then explain what happens to the denominator if you remove [Region] from the view.
PROBLEM 4APPLIED
A product manager asks you to build a dashboard that shows average order size per customer by region, but also flags any region where the average order size is more than 20% below the overall company average. Using INCLUDE and EXCLUDE LOD expressions, describe the calculated fields you would create and how you would implement the flag.
PROBLEM 5CRITICAL THINKING
Consider the filter pipeline: Data Source Filters → Context Filters → FIXED LOD → Dimension Filters → INCLUDE/EXCLUDE LOD → Measure Filters → Table Calculations. A colleague has built a dashboard using { EXCLUDE [State] : SUM([Sales]) } to show each state's sales as a share of regional total. However, when the user selects specific states in a dimension filter, the denominator (regional total) shrinks to only include the filtered states, distorting the percentages. Propose and justify a solution using either context filters or a different LOD type, and analyze the trade-offs of each approach.

Lesson Summary

INCLUDE LOD expressions add dimensions to the view-level granularity, computing aggregations at a finer grain. The result must be wrapped in an outer aggregation (AVG, MIN, MAX) to collapse back to the view level. EXCLUDE LOD expressions remove dimensions, computing at a coarser grain and replicating the result to view rows. Both are view-adaptive—they automatically adjust when you modify the dimensions on the shelves—and both execute after dimension filters in Tableau's filter pipeline.

The choice between INCLUDE and EXCLUDE maps to a clear decision: if you need to drill to a finer grain (e.g., per-customer metrics before regional rollup), use INCLUDE. If you need to reference a coarser grain (e.g., percent-of-parent, deviation from group average), use EXCLUDE. For absolute grain control independent of the view, use FIXED. These three LOD keywords, combined with Tableau's filter pipeline, give you precise, declarative control over aggregation granularity—a capability that parallels SQL's GROUP BY and window functions but within a visual interface.

Varsity Tutors • Tableau • INCLUDE/EXCLUDE LOD — Use INCLUDE/EXCLUDE LOD to control granularity