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.

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.

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.

Visual Explanation — The Tableau Order of Operations

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.

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
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
WITH 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.

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.

Tableau filter types classified by their position relative to the aggregation boundary.
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
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.

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
Step 1 — Establish the Base ViewDrag 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
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
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
Step 4 — Verify the Interaction OrderThe 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
Step 5 — Consider the Grand Total ImplicationIf 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.

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.

Practical comparison of pre- vs. post-aggregation filtering strategies.
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
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.

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.

Mapping basic filter-aggregation concepts to advanced Tableau features.
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

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.

Practice Problems

PROBLEM 1CONCEPTUAL
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?
PROBLEM 2BASIC 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?
PROBLEM 3INTERMEDIATE
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?
PROBLEM 4APPLIED
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.
PROBLEM 5CRITICAL 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?

Lesson 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 filtersmeasure 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