Tableau • Getting Started and Tableau Basics

Filters & Aggregation Interaction — Interpret how filters and aggregation interact (conceptual)

Understanding how the order of filtering and aggregation in Tableau's query pipeline fundamentally shapes the numbers you see.

Tableau illustration with a dashboard presentation, data visualization, and database
Inside this lesson 10 sections 5 questions 7 figures

SECTION 1

Historical Context & Motivation

The tension between filtering data and computing aggregates is not unique to Tableau—it has deep roots in the relational database world. When Edgar F. Codd formalized the relational model in 1970, he introduced operations like selection (σ) and projection (π) that operate on individual rows, alongside aggregate functions that collapse entire sets of rows into scalar values. SQL later codified this distinction through the WHERE clause (which filters rows before aggregation) and the HAVING clause (which filters after aggregation). This duality is the conceptual ancestor of Tableau's own multi-layered filter architecture.

1970 • Codd's Relational Model

Edgar Codd publishes "A Relational Model of Data for Large Shared Data Banks," establishing the theoretical distinction between row-level operations and aggregate operations on sets of tuples.

1986 • SQL Standard (SQL-86)

The first ANSI SQL standard formalizes WHERE (pre-aggregation filter) and HAVING (post-aggregation filter), giving developers explicit control over when filtering occurs relative to GROUP BY.

2003 • Tableau Founded at Stanford

Pat Hanrahan and Chris Stolte spin Tableau out of Stanford's VizQL research, embedding a structured query pipeline that translates visual drag-and-drop actions into optimized SQL—including a layered filter stack.

2010s • Context Filters & LOD Expressions

Tableau introduces context filters and Level of Detail (LOD) expressions, giving analysts fine-grained control over where in the pipeline filters and aggregations execute—directly addressing the interaction problem.

2020s • Modern Tableau Pipeline

The current Tableau order of operations includes extract filters, data source filters, context filters, dimension filters, measure filters, and table calculation filters—each interacting with aggregation differently.

The core question this lesson addresses is deceptively simple: when you apply a filter in Tableau, does it shrink the dataset before the aggregation runs, or does it act on already-aggregated marks? The answer depends entirely on the type of filter and its position in Tableau's order of operations. Misunderstanding this interaction is one of the most common sources of incorrect dashboards, and mastering it is essential for any data professional.

SECTION 2

Core Principles & Definitions

To reason about how filters and aggregation interact, you need a clear mental model of Tableau's internal query pipeline. At its heart, Tableau translates every view you build into a SQL-like query against the data source. The order of operations determines the sequence in which extract filters, data source filters, context filters, sets and conditional filters, dimension filters, measure (aggregate) filters, table calculation filters, and trend-line or reference-line filters are evaluated. Each layer either reduces the row-level data before aggregation or acts on aggregated results after they are computed. This ordering is not merely a performance consideration—it changes the semantic meaning of your visualization.

1

Pre-Aggregation Filters

These filters (extract, data source, context, and standard dimension filters) remove individual rows from the dataset before any SUM, AVG, or COUNT is computed. They change the input to the aggregation function.
2

Post-Aggregation Filters

Measure filters and table calculation filters act on already-aggregated marks (the visual data points). They hide marks from the view but do not alter the underlying aggregation that produced them.
3

Context Filters

A context filter is a special dimension filter that is promoted earlier in the pipeline. It creates a temporary, materialized subset of data against which all subsequent filters—including Top N and conditional filters—operate.
4

LOD Expressions & Filters

FIXED LOD expressions are computed before dimension filters but after context filters. INCLUDE and EXCLUDE LODs are computed after dimension filters. This nuance is critical for advanced analytics.
5

Aggregation Granularity

The granularity of an aggregation (e.g., SUM per category vs. SUM per category per region) is set by the dimensions in the view. Filters that remove dimension members before aggregation change the groups themselves, not just the rows within groups.
✦

KEY TAKEAWAY

Think of Tableau's pipeline like a manufacturing assembly line. Pre-aggregation filters are quality inspectors at the raw-materials stage—they remove defective parts before anything is assembled. Post-aggregation filters are inspectors at the end of the line—they pull finished products off the shelf but never change how those products were built. Choosing the wrong inspector placement means you either ship bad products or reject good ones based on stale data.

SECTION 3

Visual Explanation — The Tableau Order of Operations

Tableau Order of Operations — Filter & Aggregation Pipeline1. Extract Filters2. Data Source Filters3. Context Filters4. Dimension Filters⚙ AGGREGATIONSUM, AVG, COUNT, etc.5. Measure Filters6. Table Calc FiltersPRE-AGGREGATION ZONERows are removed BEFOREaggregation computes.• Changes SUM, AVG values• Changes COUNT results• Affects percentagesSQL analogy: WHERE clausePOST-AGGREGATION ZONEMarks are hidden AFTERaggregation. Values unchanged.SQL analogy: HAVING clause← Aggregation boundary
The diagram above shows Tableau's filter pipeline from top to bottom. Filters in the pre-aggregation zone (extract, data source, context, and dimension filters) remove rows before any aggregate function runs, thereby changing the computed values. Filters in the post-aggregation zone (measure and table calculation filters) hide marks whose aggregated values fail the condition, but the aggregation itself was already computed on the full (or pre-filtered) dataset.

Notice the critical aggregation boundary drawn as a dashed amber line in the diagram. Everything above that line modifies the raw rows fed into functions like SUM(Sales) or AVG(Profit). Everything below it operates on the already-computed aggregated values. This distinction is the single most important concept in this lesson. When you drag a dimension to the Filters shelf, you are removing rows; when you drag a measure to the Filters shelf and set a condition (e.g., SUM(Sales) > 10000), you are hiding marks that do not meet the threshold after the summation has already been calculated.

SECTION 4

How It Works — The Query Execution Model

When you build a view in Tableau, VizQL (Tableau's visual query language) translates your shelf configuration into a SQL-like query. Understanding the generated query structure reveals exactly where filters and aggregations interact. Consider a view that shows SUM(Sales) by Category with a dimension filter excluding "Furniture" and a measure filter requiring SUM(Sales) > 50000. Conceptually, VizQL generates a query analogous to the following structure.

CONCEPTUAL QUERY STRUCTURE

SELECTCategory,SUM(Sales)FROMdatasetWHERECategory≠′Furniture′←dimensionfilter(pre−aggregation)GROUPBYCategoryHAVINGSUM(Sales)>50000←measurefilter(post−aggregation)SELECT Category, SUM(Sales) FROM dataset WHERE Category ≠ 'Furniture' ← dimension filter (pre-aggregation) GROUP BY Category HAVING SUM(Sales) > 50000 ← measure filter (post-aggregation)

The WHERE clause removes rows before GROUP BY runs, so SUM(Sales) for remaining categories is computed only on non-Furniture rows. The HAVING clause then discards any category whose aggregated sum does not exceed 50,000—but the sum itself was already fully computed.

Context Filters as Subquery Materialization

When you promote a dimension filter to a context filter, Tableau conceptually materializes a temporary table containing only the rows that pass that filter. All subsequent filters and computations—including FIXED LOD expressions, Top N filters, and conditional filters—operate against this reduced dataset rather than the full data source. This is analogous to a WITH (CTE) or subquery in SQL that pre-filters before the main query runs. The practical consequence is that a Top 10 filter, which is computed based on aggregated results, will compute its ranking within the context-filtered subset rather than across all data.

CONTEXT FILTER CONCEPTUAL MODEL

WITHfiltereddataAS(SELECT∗FROMdatasetWHERERegion=′West′←contextfilter)SELECTCategory,SUM(Sales)FROMfiltereddataWHERESegment=′Consumer′←dimensionfilterGROUPBYCategoryWITH filtered_data AS ( SELECT * FROM dataset WHERE Region = 'West' ← context filter ) SELECT Category, SUM(Sales) FROM filtered_data WHERE Segment = 'Consumer' ← dimension filter GROUP BY Category

The context filter on Region creates a materialized subset. The subsequent dimension filter on Segment operates within that subset. Both are pre-aggregation, but the context filter runs first, affecting the scope of all downstream operations.

LOD Expressions and the Filter Interaction

Level of Detail (LOD) expressions add another layer of complexity. A {FIXED [Customer] : SUM(Sales)} expression computes the sum at the customer level regardless of what dimensions are in the view. Crucially, FIXED LOD expressions are computed after context filters but before dimension filters. This means that a dimension filter on Category will not affect the FIXED calculation, but a context filter on Category will. In contrast, INCLUDE and EXCLUDE LODs are computed after dimension filters, meaning they respect the standard filter shelf. This ordering is not configurable—it is hardwired into Tableau's execution model.

SECTION 5

Detailed Breakdown — Filter Types and Their Aggregation Impact

Each filter type in Tableau occupies a specific position in the order of operations. The following table classifies every major filter type, its execution phase relative to aggregation, and its concrete effect on computed values. This is the reference you should internalize to predict how any filter will behave in a real dashboard.

Filter TypePhaseActs OnEffect on Aggregation
Extract FilterPre-aggregation (earliest)Raw rows at extract creationRows permanently excluded from .hyper file; all aggregations affected
Data Source FilterPre-aggregationRows at connection levelRows excluded before any sheet; aggregations on all sheets affected
Context FilterPre-aggregation (materialized)Rows → temp tableCreates subset; Top N and FIXED LODs computed within this subset
Dimension FilterPre-aggregationRows matching dimension membersRemoves rows → changes SUM, AVG, COUNT, etc.
Measure FilterPost-aggregationAggregated marksHides marks; aggregation values unchanged; percentages may shift
Table Calc FilterPost-aggregation (latest)Computed table calc valuesHides marks; table calc still computed on full partition; running totals unaffected

Tableau filter types classified by their position relative to the aggregation boundary.

Example: SUM(Sales) by Category — Filter Impact ComparisonSame dataset, different filter types → different resultsSCENARIO A: Dimension FilterExclude "Home Office" segment (pre-agg)Technology$643,421Furniture$520,189Office Supplies$568,753Total: $1,732,363↑ Rows removed BEFORE SUMHome Office rows excluded → sums reducedPercent-of-total recalculated on subsetSCENARIO B: Measure FilterSUM(Sales) > 700,000 (post-agg)Technology$836,154Furniture$688,542HIDDENOffice Supplies$695,823HIDDENOnly Technology passes filter↑ Marks hidden AFTER SUMFull dataset used in aggregation$836,154 computed over ALL segments⚠ Key DifferenceScenario A shows smaller SUM values (fewer rows). Scenario B shows unchanged SUM values (marks just hidden).
This side-by-side comparison illustrates the same data filtered two different ways. In Scenario A, a dimension filter removes rows before summation, producing smaller totals. In Scenario B, a measure filter hides categories after summation, so the visible values are the full aggregated amounts (computed across all segments including Home Office).
⚠

Common Pitfall

A frequent mistake is using a measure filter to "remove" a category's contribution from a total, expecting it to behave like a WHERE clause. Because measure filters are post-aggregation, the total in a grand total row or a percent-of-total calculation may include the hidden category's contribution. If you need the total to reflect only visible categories, use a dimension filter instead.

SECTION 6

Worked Example — Predicting Filter-Aggregation Outcomes

Let us walk through a concrete scenario using Tableau's Superstore sample dataset. The goal is to build a bar chart of AVG(Profit) by Sub-Category, then apply multiple filters and predict their combined effect on the displayed values.

Predicting AVG(Profit) with Mixed Pre- and Post-Aggregation Filters

  1. 1

    Step 1 — Establish the Base View

    Drag Sub-Category to Rows and Profit (aggregated as AVG) to Columns. Tableau computes AVG(Profit) across all rows for each sub-category. For example, suppose "Tables" has 319 rows with a total profit of −$17,725, yielding AVG(Profit) = −$17,725 / 319 ≈ −$55.57.
    Base AVG(Profit) for Tables ≈ −$55.57 (computed over 319 rows)
  2. 2

    Step 2 — Apply a Dimension Filter (Pre-Aggregation)

    Add Region to the Filters shelf and exclude "South." This is a standard dimension filter, so it operates pre-aggregation. All rows where Region = 'South' are removed before AVG is computed. Suppose the South contributed 65 rows for Tables with a disproportionately negative average. Removing those rows changes both the numerator (total profit) and denominator (row count) of the AVG function. The new computation might be AVG(Profit) = −$12,100 / 254 ≈ −$47.64.
    AVG(Profit) for Tables changes to ≈ −$47.64 — the dimension filter altered the aggregation input.
  3. 3

    Step 3 — Apply a Measure Filter (Post-Aggregation)

    Now add AVG(Profit) to the Filters shelf and set the condition: AVG(Profit) > 0 (show only profitable sub-categories). This is a measure filter—it runs after aggregation. Tableau first computes AVG(Profit) for every sub-category using the already-filtered rows (South excluded). Then it hides any sub-category whose AVG(Profit) ≤ 0. Tables (−$47.64) would be hidden. Importantly, the displayed sub-categories retain their exact aggregated values; no recomputation occurs.
    Tables is hidden from the view — but its AVG(Profit) was already computed as −$47.64 on the South-excluded dataset.
  4. 4

    Step 4 — Verify the Interaction Order

    The pipeline executed in this order: (1) Dimension filter on Region removed South rows from the dataset; (2) AVG(Profit) was computed per Sub-Category on the reduced dataset; (3) Measure filter on AVG(Profit) > 0 hid unprofitable sub-categories. If we had instead used Region as a context filter, the result would be identical in this case because the context filter also runs pre-aggregation. The difference would only surface if we also had a FIXED LOD expression or a Top N filter, which would then be scoped to the context.
    Execution order confirmed: Dimension filter → Aggregation → Measure filter
  5. 5

    Step 5 — Consider the Grand Total Implication

    If we enable "Show Grand Total" for rows, the grand total AVG(Profit) will be computed across all visible sub-categories. Because the measure filter hid Tables and other unprofitable sub-categories, the grand total appears higher than if we had used no measure filter. However, if we had used a dimension filter on Sub-Category instead (excluding Tables directly), the rows belonging to Tables would have been removed entirely, and the grand total would reflect a different computation since the overall average would be recalculated without those rows. This subtle difference is a common source of misinterpretation in dashboards.
    Grand totals behave differently depending on whether you used a pre- or post-aggregation filter to exclude data.

SECTION 7

Strengths, Limitations & Common Mistakes

Knowing the conceptual distinction between pre- and post-aggregation filters is necessary, but you also need to understand the practical trade-offs of each approach. The table below summarizes when each filter type is advantageous, when it introduces risk, and the performance considerations that matter at scale.

ConsiderationPre-Aggregation FiltersPost-Aggregation Filters
Aggregation impactChanges computed values (SUM, AVG, COUNT, etc.)Values remain unchanged; marks are only hidden
Grand totalsGrand total recalculated on reduced datasetGrand total may include hidden marks (depends on settings)
Percent-of-totalDenominator shrinks; remaining categories sum to 100%Denominator unchanged; visible slices may not sum to 100%
PerformanceReduces data processed → faster queries at scaleFull dataset still aggregated → no query-side savings
LOD interactionContext filters affect FIXED LODs; dimension filters do notNo effect on LOD computation
Best use caseScoping analysis to a meaningful subset (e.g., single region, date range)Hiding outliers or low-volume marks without distorting aggregations

Practical comparison of pre- vs. post-aggregation filtering strategies.

✦

KEY TAKEAWAY

Think of pre-aggregation filters as editing the source code of a program before compilation, and post-aggregation filters as selectively hiding lines from the compiled output. In the first case, the compiled binary is fundamentally different. In the second case, the binary is identical—you have merely chosen not to display certain results. Choosing the wrong approach is like debugging the wrong version of your code: you will draw incorrect conclusions because the underlying data does not match your expectations.

SECTION 8

Connection to Advanced Theory — LOD Expressions and Tableau Prep

The filter-aggregation interaction you have learned in this lesson is the foundation for more advanced Tableau features. As you progress, you will encounter scenarios where the default order of operations is insufficient and you need explicit control over when computations happen. LOD expressions (FIXED, INCLUDE, EXCLUDE) are the primary mechanism for overriding the default granularity of aggregation, and their behavior is tightly coupled to the filter pipeline. Similarly, Tableau Prep allows you to apply filters and aggregations at the data-preparation stage, effectively pushing these operations before Tableau Desktop's pipeline even begins.

ConceptThis Lesson (Basics)Advanced Extension
Dimension filterRemoves rows before SUM/AVG; applied via Filters shelfFIXED LODs ignore dimension filters; use context filters to scope FIXED LODs
Measure filterHides marks post-aggregation; does not change valuesTable calculations can reference hidden marks; WINDOW_SUM includes filtered-out values
Context filterMaterializes subset; scopes Top N filtersScopes FIXED LODs; multiple context filters stack as AND conditions on materialized set
Order of operationsLinear pipeline: extract → data source → context → dimension → agg → measure → table calcLOD expressions insert additional aggregation passes at specific points; sets and parameters add further branching

Mapping basic filter-aggregation concepts to advanced Tableau features.

As a forward-looking note, many Tableau performance-tuning strategies revolve around pushing filters earlier in the pipeline. Extract filters are the most performant because they physically reduce the data volume. Data source filters avoid transmitting unnecessary rows. Context filters reduce the working set for complex downstream calculations. Understanding the filter-aggregation interaction is therefore not just an analytical correctness concern—it is also a computational complexity concern that directly impacts dashboard responsiveness, especially when working with millions of rows or real-time connections.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

A Tableau view shows SUM(Sales) by Category. You add Region to the Filters shelf and exclude "West." Is this a pre-aggregation or post-aggregation filter? How does it affect the displayed SUM(Sales) values?
Show answer
Region is a dimension, so filtering it creates a pre-aggregation (dimension) filter. It operates like a SQL WHERE clause, removing all rows where Region = 'West' before Tableau computes SUM(Sales) for each Category. This means the displayed SUM(Sales) values will be smaller than before because the rows from the West region no longer contribute to the summation. The denominator for any percent-of-total calculation also shrinks, so the remaining regions' percentages are recalculated to sum to 100%.

Question 2: BASIC CALCULATION

A dataset has three categories: A (500 rows, total sales $100,000), B (300 rows, total sales $60,000), C (200 rows, total sales $30,000). You apply a measure filter: SUM(Sales) > 50,000. Which categories are visible, and what SUM(Sales) values do they display? Does the grand total include Category C's $30,000?
Show answer
Categories A ($100,000) and B ($60,000) are visible because their SUM(Sales) exceeds $50,000. Category C ($30,000) is hidden. The displayed SUM(Sales) values for A and B are unchanged at $100,000 and $60,000 respectively, since the measure filter acts post-aggregation. Regarding the grand total, Tableau's default behavior for subtotals/grand totals with measure filters is to compute the total across all marks (visible and hidden), which would be $190,000. However, this behavior can vary depending on settings and Tableau version—in many configurations, the grand total reflects only visible marks ($160,000). This is a common source of confusion and should be verified in practice.

Question 3: INTERMEDIATE

You have a view with AVG(Profit) by Sub-Category and you want to show only the Top 5 sub-categories by AVG(Profit), but only within the "East" region. You set Region = 'East' as a regular dimension filter and Sub-Category as a Top 5 filter. Will the Top 5 be computed within the East region only, or across all regions? What would you change to ensure the Top 5 is scoped to the East?
Show answer
In Tableau's default order of operations, Top N filters and regular dimension filters are evaluated at the same level (both are dimension-level filters). This means the Top 5 computation may use data from all regions rather than being scoped to East only, because Tableau does not guarantee that one dimension filter runs before another at the same pipeline stage. To ensure the Top 5 is computed within the East region exclusively, you should promote the Region = 'East' filter to a context filter (right-click the filter → 'Add to Context'). Context filters execute before standard dimension filters and Top N filters, creating a materialized subset that contains only East rows. The Top 5 ranking will then be computed against this East-only subset, giving you the correct result.

Question 4: APPLIED

You are building a dashboard for a sales team. They want a bar chart showing SUM(Sales) by Product Name with a quick filter for Segment (Consumer, Corporate, Home Office). They also use a FIXED LOD expression: {FIXED [Product Name] : SUM(Sales)} as a reference line. When the user selects Segment = 'Consumer', they notice the reference line values do not change, but the bar heights do. Explain why and propose a fix.
Show answer
The Segment quick filter operates as a standard dimension filter, which runs after FIXED LOD expressions in Tableau's order of operations. The FIXED LOD expression {FIXED [Product Name] : SUM(Sales)} computes SUM(Sales) for each product across ALL segments because it is evaluated before the Segment dimension filter takes effect. The bar heights change because the view-level SUM(Sales) is computed after the dimension filter removes non-Consumer rows. To make the FIXED LOD respect the Segment filter, promote the Segment filter to a context filter. Context filters execute before FIXED LOD expressions, so {FIXED [Product Name] : SUM(Sales)} will then compute within the Consumer-only subset, and the reference line will update to match the bar heights. Alternatively, you could rewrite the calculation as an INCLUDE LOD: {INCLUDE [Product Name] : SUM(Sales)}, which is computed after dimension filters and would naturally reflect the Segment selection.

Question 5: CRITICAL THINKING

A colleague argues that post-aggregation filters (measure filters) are always inferior to pre-aggregation filters because they 'waste computation on data that won't be shown.' Construct a counterargument with at least two scenarios where a post-aggregation filter is the correct and even necessary choice. Then analyze: from a computational complexity perspective (e.g., if the dataset has N rows and K groups), what is the cost difference between filtering pre- vs. post-aggregation?
Show answer
The colleague's argument oversimplifies the problem. Post-aggregation filters are the correct choice in at least two important scenarios. First, when you need table calculations (e.g., running totals, percent-of-total, or RANK) to be computed on the full dataset before hiding certain marks—removing rows pre-aggregation would corrupt the calculation. For instance, a running sum across months requires all months to produce correct cumulative values; hiding a single month post-aggregation preserves the sequence. Second, when a user wants to see 'only categories with revenue above $X' without distorting the underlying aggregation—this is semantically a HAVING clause, and using a dimension filter to exclude specific categories would change the composition of averages and sums in ways that may be analytically misleading. From a complexity standpoint, a pre-aggregation filter on N rows with selectivity s produces sN rows for the GROUP BY, costing O(sN) for the scan and O(sN × log(K)) for the sort-based grouping. A post-aggregation filter processes all N rows (O(N log K) for grouping), then applies a trivial O(K) filter on the K groups. The pre-aggregation approach is cheaper when s is significantly less than 1, but the post-aggregation cost overhead is merely O((1−s)N × log K), which is irrelevant when K << N. The choice should be driven by semantic correctness, not performance, unless N is extremely large.

SUMMARY

Lesson Summary

Summary

The interaction between filters and aggregation in Tableau is governed by a strict order of operations. Pre-aggregation filters—including extract filters, data source filters, context filters, and dimension filters—remove rows from the dataset before aggregation functions like SUM, AVG, and COUNT are computed, thereby altering the values produced. Post-aggregation filters—measure filters and table calculation filters—hide marks whose aggregated values fail a condition, without changing the underlying computation.

The critical nuance lies in context filters, which materialize a subset of data and scope downstream operations including FIXED LOD expressions and Top N filters. FIXED LODs are computed after context filters but before dimension filters, while INCLUDE and EXCLUDE LODs respect dimension filters. Choosing the wrong filter type leads to incorrect aggregations, misleading grand totals, and dashboards that silently misrepresent the data. Always identify where in the pipeline your filter executes before trusting the numbers.

Varsity Tutors • Tableau • Filters & Aggregation Interaction