01 / 21

Context Filters
in Tableau

Learn how context filters change the order of operations in Tableau, why they matter for accurate analysis, and when to use them.

Tableau Data Visualization

What Is a Filter in Tableau?

A filter restricts the data shown in a visualization. When you drag a dimension or measure to the Filters shelf, Tableau removes rows that don't match your criteria before rendering the view.

Tableau's Order of Operations

Tableau processes filters in a fixed pipeline. Each stage narrows the data before the next stage runs. Understanding this sequence is the key to mastering context filters.

1. Extract Filters 2. Data Source Filters 3. Context Filters 4. Dimension Filters 5. Measure Filters 6. Table Calc Filters Runs BEFORE dimension filters

What Is a Context Filter?

A context filter is a regular dimension filter that you promote to run earlier in the pipeline. It creates a temporary table of results, and all other filters then operate on that smaller dataset instead of the full data source.

Regular Filter
All dimension filters run simultaneously and independently against the full data.
Context Filter
Runs first, creating a subset. Other filters then apply only within that subset.

Why Does Order Matter?

When two regular filters run independently, each one evaluates against the entire data source. This means a "Top N" filter calculates the top N across all data, not just the subset you care about. Context filters solve this by narrowing the data first.

The Core Rule

Full Data Context Filter Subset Top N Filter Final View

Without vs With Context Filter

Without Context Filter Product Category Sales Phone Tech $340K Chairs Furn $328K Storage Supp $224K Tables Furn $207K Copiers Tech $150K Top 5 across ALL categories Only 2 Tech products appear With Context Filter Product Category Sales Phone Tech $340K Copiers Tech $150K Machines Tech $120K Accessories Tech $80K Supplies Tech $47K Top 5 within Technology only All 5 are Tech products

Regular vs Context Filters

Regular Filter Context Filter
Execution Order All run simultaneously Runs before other filters
Creates Temp Table No Yes
Affects Top N Top N on full data Top N on subset
Performance Faster for small data Overhead for temp table
Visual Cue Normal pill color Grey pill on shelf

When to Use Context Filters

1. Top N within a group
You need the Top or Bottom N items constrained to a specific category or region.
2. Dependent filters
One filter's results should define the scope for another filter's computation.
3. Performance on large data
A context filter can reduce dataset size early, making subsequent filters faster.

How to Apply a Context Filter

1
Drag a dimension to the Filters shelf (e.g., Category).
2
Select the values you want to keep (e.g., "Technology").
3
Right-click the filter pill on the Filters shelf.
4
Choose "Add to Context". The pill turns grey, and the view updates.
5
Now add your dependent filter (e.g., Top 5 by Sales). It operates on the context subset.

Example 1: Top 3 Products in Furniture

Goal: Show the 3 best-selling products within the Furniture category only.

Filters Shelf Category: Furniture CTX Top 3 by Sales Result Output Chairs $328K Tables $207K Bookcases $115K ✓ All 3 are Furniture items Context ensured correct scope

Example 2: Dependent Filters for Regions

Goal: Show only customers in the West region whose total sales exceed \( \$5,000 \). You need the region filter to run first so the sales calculation only considers West data.

1
Add Region to Filters, select "West".
2
Right-click the Region pill and choose "Add to Context".
3
Add a filter on \( \text{SUM(Sales)} \) with the condition: \( > \$5,000 \).
4
The sales filter now evaluates only West region data, giving accurate results.

Example 3: Performance Optimization

Scenario: Your data source has 50 million rows. You only care about the current year. Adding Year as a context filter creates a temporary table of ~10 million rows, making all subsequent filters and calculations much faster.

50M rows 50M All Years Context: Year=2024 10M rows 10M 2024 Only Other Filters Fast! 1.2M

Context Filters and Sets

Context filters also influence fixed sets and conditional sets. A set defined as "Top 10 by Profit" will compute those Top 10 within the context, not across the entire data source.

Without Context
Set "Top 10 Customers by Profit" evaluates across the entire dataset. Filtering to a single state afterward won't change which customers are in the set.
With Context
Adding State = "California" as context means the Top 10 set recalculates within California only. The set membership updates.

Common Mistakes

✕ Using context filters unnecessarily
Context filters create temp tables with overhead. If you don't need dependent filtering or Top N scoping, a regular filter is faster.
✕ Too many context filters
Each context filter regenerates the temp table. Adding many context filters can slow performance instead of improving it.
✕ Forgetting filter order
Expecting a regular filter to constrain a Top N or set computation. If results look wrong, check whether a context filter is needed.

Summary Comparison

Regular Filter Context Filter
Pipeline Position Stage 4 (Dimension) Stage 3 (Before Dimension)
Temp Table No Yes
Top N Scope Full data Context subset
Set Membership Full data Context subset
Best For Simple filtering Dependent, scoped analysis
Pill Color Blue/Green Grey

Question 1 of 5

What does a context filter create when applied in Tableau?

Question 2 of 5

You want the Top 5 products by sales within the Office Supplies category. Which approach gives the correct result?

Question 3 of 5

In Tableau's order of operations, context filters execute at which stage?

Question 4 of 5

Which of the following is a disadvantage of using context filters?

Question 5 of 5

How can you visually identify a context filter on the Filters shelf in Tableau?