What Does Add to Context Do in Tableau?

Cody Schneider7 min read

Ever set up filters in Tableau that somehow don't give you the results you expect? One of the most common reasons is not understanding Tableau's "Order of Operations" - the specific sequence it follows when applying filters and calculations. This is exactly where the "Add to Context" feature becomes essential. This article breaks down what a context filter is, how it works, and shows you exactly when to use it to get the right results and improve dashboard performance.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Understanding Tableau's Order of Operations

Tableau doesn't apply all your filters simultaneously. It processes them in a fixed sequence, and this hierarchy dramatically impacts your final visualization. Forgetting this order is like trying to frost a cake before you’ve baked it - you'll end up with a mess.

Here’s a simplified look at the filter analytics pipeline:

  1. Extract Filters: Filters applied when creating a data extract (.hyper file) from your source.
  2. Data Source Filters: Filters applied at the data source level, restricting what data enters your workbook entirely.
  3. Context Filters: This is where our feature comes in. These are applied before any standard filters on your worksheet.
  4. Dimension Filters: These are the most common filters you drag and drop, like filtering by category, region, or date. This level also includes filters for TOP N, conditional logic, and Sets.
  5. Measure Filters: Filters applied directly to the numeric values or measures in your view (e.g., showing only sales greater than $1,000).

The key takeaway is that context filters are processed before dimension filters. By adding a dimension filter to context, you bump it up the priority list, forcing Tableau to deal with it first.

What Exactly is a Context Filter?

Think of a context filter as a gatekeeper for your worksheet. When you apply a standard dimension filter, Tableau scans the entire dataset to find the relevant rows. When you elevate that filter by choosing "Add to Context," you’re telling Tableau to first create a smaller, temporary table containing only the data that passes through that context filter.

From that point on, any other dimension filters, calculations, or TOP N analyses you apply to that worksheet will run against this smaller, pre-filtered table, not the original, full dataset.

This does two critical things:

  • It changes the outcome of your analysis, especially when using features like TOP N filters or certain Level of Detail (LOD) calculations.
  • It can significantly speed up your dashboards, because subsequent queries are running against a much smaller subset of your data.

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.

How to "Add to Context" in Tableau: A Step-by-Step Example

Showing is better than telling. Let's walk through a classic scenario where "Add to Context" is not just helpful, but necessary to get the right answer.

The Goal: Find the top 5 highest-selling products within the "Technology" category from the Sample - Superstore dataset.

Without the context filter, you'll get the wrong answer. Here's why and how to fix it.

The Problem: Getting the Wrong "Top 5"

  1. Start by creating a simple bar chart showing SUM(Sales) by Product Name.
  2. Apply a standard dimension filter to show products in the Technology category only.
  3. Drag another instance of Product Name to Filters.
  4. In the filters pop-up, go to the 'TOP' tab. Choose 'By Field' and set it to Top 5 by SUM(Sales).

You'll notice something strange. The view doesn't show five bars as expected.

This occurs because both the category filter and the TOP 5 product filter are dimension filters, so Tableau applies them at the same time. It first finds the overall top 5 selling products across all categories and then shows those within the "Technology" category. This isn't what we want.

The Solution: Adding the Category Filter to Context

To get the correct result, we need to tell Tableau: “First, focus on the Technology category data.” Then, find the top 5 selling products.

Here's how to do it:

  1. On the Filters shelf, right-click on the Category filter (ensure only "Technology" is selected).
  2. From the dropdown, select Add to Context.

You will notice that the category filter turns grey. This indicates that it is now a context filter.

Look at your chart now. It will correctly display the top 5 selling products within the Technology category. Success!

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Key Scenarios: When Should You Use Context Filters

Apart from the classic TOP N example here, there are other practical situations where you should definitely reach for "Add to Context."

1. Improving Dashboard Performance

If you are working with an enormous dataset (millions of rows), you can use context filters to drastically improve your dashboard’s performance. Imagine you have a global dashboard showing sales data and customer behavior. You're only interested in seeing data for the current year.

By applying your filter as a context, all subsequent calculations and queries on that dashboard (e.g., clicking on a region or filtering by product type) will run much faster because Tableau is no longer scanning the entire dataset. Instead, it only looks at the smaller temporary table for the current year.

2. Creating Dependent TOP N or BOTTOM N Filters

This is the example we walked through, but it's worth repeating because this is a common use-case.

Anytime you need to apply a TOP or BOTTOM N filter to a preferred subset of your data (like the best selling books only in the current category), you'll need "Add to Context."

3. Controlling the Scope for LOD (Level of Detail) Expressions

This is another more advanced use-case but is incredibly powerful. By default, FIXED LOD expressions compute before regular dimension filters are applied. That means that if you add a dimension filter (e.g., Category) it will not change the result of a FIXED calculation. However, FIXED LODs are calculated after context filters, which means a context filter can include them.

Example: Assume you have a calculation: { FIXED [Region]: SUM([Sales]) }. This calculation finds the total sales for each region, regardless of what's in the view. If you apply a standard category filter, it evaluates for this FIXED calculation on the change. However, if you add the category filter to context, Tableau recalculates the FIXED expression based solely on the data in the selected category. This ensures you see the correct aggregated totals in your view.

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.

Context Filters vs. Data Source Filters: What's the Difference?

This is another frequent area of confusion. Context filters and data source filters might sound similar but they have distinct purposes.

Data Source Filters

  • Order of Application: They are applied at the highest level in Tableau's Order of Operations. They filter data before it ever gets into the Tableau workbook.
  • Scope: They are global. They affect the entire data source and all worksheets that use it.
  • Use Case: Ideal for setting up data-level security, like ensuring a project or dataset user cannot see. Or drastically reducing the overall size of your data source, perfect for lightweight workbooks.

Context Filters

  • Order of Application: They are applied after data source filters but before dimension filters. They create a smaller subset of data for one specific worksheet.
  • Scope: They are local. They only affect the sheets (and sets or groups) on which they're applied.
  • Use Case: Ideal for improving dashboard performance, creating dependent TOP N filters, and controlling the scope of FIXED LOD expressions.

Final Thoughts

When utilized correctly, "Add to Context" in Tableau's filtering is all about getting the lens to focus more accurately on the data you need. It's essential for controlling the fine-grained calculations, displaying dependent sets like TOP N, and managing LOD calculations correctly, making it a powerful way to speed up any dashboard with large datasets.

Remembering the order of operations and keeping that in mind when working through data analytics can save you a lot of grief. It's one of the reasons many Tableau experts rely on Graphed to help manage filters and improve performance. You can start creating those precise, analysis-loving dashboards that everyone talks about. The clearer your goals in filtering, the better the insights you provide, and the more motivated your team will be to dive deeper.

Related Articles