01 / 20

Filters &
Aggregation Interaction

Master how filters and aggregation functions interact in Tableau to build accurate, meaningful visualizations.

Tableau

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.

SUM
Adds all values in the group together
AVG
Computes the arithmetic mean of all values
COUNT
Counts the number of non-null records

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.

Extract Filters
Applied when importing data: rows are excluded before they even enter Tableau
Dimension Filters
Remove rows based on categorical values before aggregation occurs
Measure Filters
Filter on aggregated results: applied after aggregation is computed

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.

Raw Data All rows Filter? Filtered Subset of rows Aggregate Aggregated Summary values Filter? V Pre-aggregation Post-aggregation

Tableau's Order of Operations

Tableau processes queries in a fixed pipeline. Filters at each stage affect only the data available to subsequent stages.

1. Extract Filters 2. Data Source Filters 3. Context Filters 4. Dimension Filters ← AGGREGATION happens here 5. Measure Filters 6. Table Calc Filters Pre-Aggregation Post-Agg

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.

Without Context
All dimension filters run independently on the full dataset, which can cause unexpected "Top N" results
With Context
A context filter narrows the universe first, so a "Top 10" filter correctly applies to the reduced set

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.

Hides, Not Removes
A table calc filter that hides "Q4" still includes Q4 data in running totals
Use Case
Show only months where running total exceeds a threshold, without distorting the calculation

How to Apply This Knowledge

1
Identify your question. Are you filtering rows or filtering aggregated results?
2
Choose the right filter type. Use dimension filters for row-level conditions, measure filters for aggregated conditions.
3
Check for context. If using Top N or relative filters, consider adding a context filter first.
4
Verify your results. Compare totals with and without the filter: does the aggregation change as expected?
5
Preserve table calcs. If using running totals or percent-of-total, use table calc filters to hide marks without distorting the calculation.

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.

Before Filter East $40K West $35K North $25K South $20K Total: $120K Filter After Dimension Filter East $40K West $35K Total: $75K

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 \).

All Aggregated East $40K West $35K North $25K South $20K $30K Filter After Measure Filter East $40K West $35K Shows: $40K, $35K

Example 3: How Filters Change \( \text{AVG} \)

Consider 5 transactions: $10, $20, $30, $100, $200. The overall \( \text{AVG} = \frac{360}{5} = 72 \).

Dimension Filter
Filter out transactions \( > \$50 \) before aggregation: remaining = $10, $20, $30. Now \( \text{AVG} = \frac{60}{3} = 20 \).
Measure Filter
Aggregate first per group, then hide groups. If all 5 are in one group, \( \text{AVG} = 72 \) is computed, then shown or hidden as a whole.

Example 4: Context Filter + Top N

Goal: find the Top 3 products by sales in the Furniture category.

Without Context
Tableau computes Top 3 across all categories, then filters to Furniture. You might see 0-2 results if the top 3 overall are not Furniture.
With Context
Set Category = "Furniture" as a context filter. Tableau first narrows to Furniture, then computes Top 3 within that subset.

Common Mistakes

✕ Filtering Rows After Aggregation
Using a dimension filter when you actually need a measure filter, causing unexpected changes to your totals and averages.
✕ Forgetting Context Filters
Applying a Top N filter alongside a category filter without promoting the category to context, resulting in missing or incorrect "Top" results.
✕ Confusing Table Calc Filters
Using a dimension filter when you need a table calc filter, which unintentionally recalculates running totals or percent-of-total values.

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?