Filters &
Aggregation Interaction
Master how filters and aggregation functions interact in Tableau to build accurate, meaningful visualizations.
What Is Aggregation?
Aggregation is the process of combining multiple rows of data into a single summary value. In Tableau, every measure placed on a shelf is automatically aggregated: \( \text{SUM} \), \( \text{AVG} \), \( \text{COUNT} \), \( \text{MIN} \), \( \text{MAX} \), and more.
What Are Filters?
Filters restrict which data rows Tableau uses before or after computing aggregations. Different filter types operate at different stages of the data pipeline.
Why Order Matters
Because filters can act before or after aggregation, the same filter condition can produce completely different results depending on when it is applied. This is the central concept of filter-aggregation interaction.
Tableau's Order of Operations
Tableau processes queries in a fixed pipeline. Filters at each stage affect only the data available to subsequent stages.
The Core Rule
Dimension vs Measure Filters
| Dimension Filter | Measure Filter | |
|---|---|---|
| When applied | Before aggregation | After aggregation |
| Operates on | Individual rows | Aggregated values |
| Example | Category = "Furniture" | \( \text{SUM}(\text{Sales}) > 5000 \) |
| Effect on AVG | Changes which rows are averaged | Hides groups after averaging |
| SQL analogy | WHERE clause | HAVING clause |
The Role of Context Filters
A context filter creates a temporary, filtered subset of data. All other filters, including dimension filters, then operate only on this subset. Context filters execute before dimension filters in the pipeline.
Table Calculation Filters
Table calculation filters are the last in the order of operations. They hide marks from the view but do not remove the underlying data from the aggregation. This means running totals and percent-of-total calculations still use all aggregated values.
How to Apply This Knowledge
Example 1: Dimension Filter on Sales
A store has sales data across 4 regions. We want \( \text{SUM}(\text{Sales}) \) for only the East and West regions.
Example 2: Measure Filter on Sales
Same data, but now we aggregate first, then apply a measure filter: show only regions where \( \text{SUM}(\text{Sales}) > 30{,}000 \).
Example 3: How Filters Change \( \text{AVG} \)
Consider 5 transactions: $10, $20, $30, $100, $200. The overall \( \text{AVG} = \frac{360}{5} = 72 \).
Example 4: Context Filter + Top N
Goal: find the Top 3 products by sales in the Furniture category.
Common Mistakes
Summary of Filter Types
| Filter Type | When | Affects Aggregation? | SQL Equivalent |
|---|---|---|---|
| Extract / Data Source | First | Yes: rows excluded | Sub-query |
| Context | Early | Yes: narrows universe | CTE / Subquery |
| Dimension | Before agg | Yes: changes input | WHERE |
| Measure | After agg | No: hides groups | HAVING |
| Table Calc | Last | No: hides marks | Post-processing |
Question 1 of 5
You have a dataset with 1,000 sales rows across 4 regions. You add a dimension filter to keep only "West." What happens to \( \text{SUM}(\text{Sales}) \)?
Question 2 of 5
A measure filter is set to show only regions where \( \text{SUM}(\text{Sales}) > 50{,}000 \). Which statement is true?
Question 3 of 5
You want the Top 5 customers by profit within the Technology category. You add a filter for Category = "Technology" and a Top 5 filter on Profit. The view shows only 2 customers. What should you do?
Question 4 of 5
You have a running total of monthly sales. You want to hide December from the view without recalculating the running total. Which filter type should you use?
Question 5 of 5
In SQL, a Tableau dimension filter is most analogous to which clause?