What is Context in Tableau?
You’ve built a powerful Tableau dashboard, but something isn’t quite right. Your "Top 10 Products" view shows only three products when you filter by a specific category. This common and frustrating issue often comes down to one critical concept: Tableau's order of operations. This article will show you how to solve this and other problems by using one of the most useful tools in your Tableau toolkit — the context filter.
We'll walk through what context filters are, when to use them, and go step-by-step through a practical example that will make the concept click.
First, Let's Talk About Tableau's Order of Operations
Before you can truly appreciate context filters, you have to understand that Tableau doesn’t just apply all your filters at once. It processes calculations and filters in a specific, predictable sequence known as the order of operations. Think of it like a set of assembly line stations, data passes through each station in order before moving to the next.
Here’s a simplified version of that sequence:
- Extract Filters: Filters applied when creating a data extract (.hyper file).
- Data Source Filters: Filters applied at the data source level.
- Context Filters: This is our key player. It's a special type of filter we'll focus on.
- FIXED Level of Detail (LOD) Expressions: These powerful calculations are computed here.
- Dimension Filters: These are the standard, "normal" filters you drag and drop onto the Filters shelf.
- INCLUDE/EXCLUDE Level of Detail (LOD) Expressions: These LODs are computed after dimension filters.
- Measure Filters: Filters applied to aggregated measures (like SUM(Sales) > $1,000).
The most important takeaway is that Context Filters (number 3) are applied before many other operations, including standard Dimension Filters (number 5). This distinction is the source of many common reporting issues.
So, What Exactly Is a Context Filter?
A context filter is a special filter in Tableau that creates a temporary, smaller dataset for the calculations on a specific worksheet. When you apply a filter "to context," you are essentially telling Tableau, "Filter our data with this first , before you run any other major calculations or dimension filters on this sheet."
Think of it this way:
- A standard dimension filter is like looking at your entire company's sales data and then putting a lens over it to only see the "Home Office" category. All the underlying data is still there, you're just viewing a portion of it.
- A context filter is like telling your assistant to create a separate report containing only "Home Office" sales. Any further questions you ask will be directed at this smaller, pre-filtered report, not the full dataset.
In the Tableau interface, you can spot a context filter easily. When you add a dimension or measure filter to context, its pill on the Filters shelf turns from the usual blue or green to a distinct gray color. This visual cue is a helpful reminder that it’s being prioritized in the order of operations.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
The "Top N" Problem: When and Why You Need a Context Filter
The most common scenario where context filters become essential is when you combine a "Top N" filter with other dimension filters. Let's walk through an example using the sample Superstore dataset that comes with Tableau.
The Goal: See the Top 10 Selling Products within the "Technology" Category
This seems simple enough. Logically, we need two filters: one for the category and one to find the Top 10 products.
Step 1: The Initial (Incorrect) View
First, we build a basic bar chart showing sales by product.
- Drag
Product Nameto Rows. - Drag
Salesto Columns and sort in descending order. - Drag
Product Nameto the Filters shelf. - In the filter dialog box, go to the Top tab. Select "By field:", and set it to "Top 10 by Sales Sum". Click OK.
Great! You now have a view of the Top 10 selling products across the entire company. Now, let’s try to filter this down for just the "Technology" category.
- Drag
Categoryto the Filters shelf. - Check the box for "Technology" and click OK.
Suddenly, your view might only show three or four products instead of ten. What happened?
This is the order of operations at play. Tableau first identified the Top 10 products from the entire dataset. After creating that list of 10 specific products, it then applied your dimension filter for "Technology," checking which of those 10 happen to fall into that category. It turns out only a few of the overall top sellers are tech products.
Step 2: The Solution - Adding the Category Filter to Context
To get the correct result, we need to tell Tableau to filter for "Technology" before it calculates the Top 10 products. We do this by elevating the Category filter to a context filter.
- Find the
Categoryfilter on your Filters shelf. - Right-click on the pill.
- Select Add to Context from the menu.
You’ll notice the Category pill immediately turns gray. Your view will instantly update, and you will now see the correct list of the 10 best-selling products exclusively from within the Technology category.
By making it a context filter, you changed the sequence. Tableau first created a temporary dataset containing only Technology products. Then, it ran the Top 10 calculation on that smaller, relevant dataset, giving you the answer you were looking for all along.
Beyond "Top N": Other Scenarios for Context Filters
While solving the "Top N" puzzle is the most common use case, context filters are valuable in several other important situations.
Improving Dashboard Performance
If you have a dashboard built on millions of rows of data with multiple interactive filters, performance can be sluggish. Applying one or two key filters to context — especially on dimensions that significantly reduce the dataset size (like a filter for a specific year, region, or business unit) — can dramatically speed up the dashboard. This is because all other filters and calculations will run against the much smaller, context-filtered temporary table instead of the full dataset.
Controlling FIXED Level of Detail (LOD) Expressions
By default, FIXED LOD expressions are computed before dimension filters. This means they intentionally ignore most standard user filters on your dashboard. For example, {FIXED [Category] : SUM([Sales])} will always calculate the total sales for the entire category, regardless of which Sub-Categories you've selected in a dimension filter.
However, FIXED expressions are subject to context filters. If you want a user’s filter selection to apply to your FIXED calculation, you simply need to add that specific filter to the context.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Creating Dependent or Cascading Filters
Imagine you have two filters: "Region" and "State." When a user selects "West," you want the "State" filter to only show states within the West region (California, Oregon, Washington, etc.), not all 50 states. This is a classic "dependent filter" scenario.
You can achieve this in Tableau using context filters:
- Add a filter for "Region."
- Add a filter for "State."
- Right-click the "Region" filter and select Add to Context.
- Click the dropdown arrow on the "State" filter card and select Only Values in Context.
Now, the "Region" selection will create the temporary dataset, and the "State" filter will only show values relevant to that context.
Things to Keep in Mind When Using Context Filters
While powerful, you shouldn't add every filter to the context. Here are a few best practices:
- Use them intentionally: Don't make everything a context filter. Use them only when you have a specific need: fixing a 'Top N' calculation, controlling an LOD, or for a significant performance gain.
- They aren't a magic performance booster: Creating the temporary table for a context filter can be a resource-intensive task for Tableau. Using a context filter on a high-cardinality dimension (like Product SKU or Customer ID) with millions of unique values could actually slow your dashboard down. They work best on filters with fewer distinct members, like a region, year, or a high-level category.
- Clarity is important: Too many gray context pills on the filter shelf can make it hard for others (or your future self) to understand the logic. Stick to a minimal, effective number of context filters per worksheet.
Final Thoughts
Getting a handle on Tableau's order of operations, especially how context filters work, moves you from a beginner to an intermediate user. It’s the key to solving some of the most common analytical puzzles, like incorrect "Top N" rankings, and gives you finer control over complex calculations and dashboard performance.
Learning foundational concepts like context filters is essential for using complex BI tools, but it highlights the steep learning curve many teams face. At Graphed, we started with a different premise: what if you didn't have to learn a tool's internal logic to get answers? Instead of building reports and then wrestling with why they are showing the wrong data, our approach lets you just ask in plain English, "Show me my top 10 best-selling products from the technology category." We automatically connect your data, interpret your question, and build the right visualization every time, getting you from question to real-time insight in seconds.
Related Articles
How to Create Facebook Ads API for Claude Code
Create a Meta Marketing API access token that never expires, using a system user, so Claude Code can pull Facebook ad reports and manage campaigns.
ClickHouse vs Postgres: When to Switch to Columnar
Comparing ClickHouse vs PostgreSQL means matching storage architecture to workload. Row storage wins for transactions. Columnar wins for scan-heavy analytics.
Google Ads for Orthodontists: Get More Booked Consults
Most orthodontic Google Ads campaigns waste money on low-intent searches. The problem is structure, not the platform.