Was this page helpful?
Yes No
Have a comment? Please leave it here. Thanks for your feedback!
All Tableau Help > Tableau Desktop and Web Authoring Help > 
Applies to: Tableau Desktop

Improve View Performance with Context Filters

By default, all filters that you set in Tableau are computed independently. That is, each filter accesses all rows in your data source without regard to other filters. However, you can set one or more categorical filters as context filters for the view. You can think of a context filter as being an independent filter. Any other filters that you set are defined as dependent filters because they process only the data that passes through the context filter.

You may create a context filter to:

For example, suppose you’re in charge of breakfast products for a large grocery chain. Your task is to find the top 10 breakfast products by profitability for all stores. If the data source is very large, you can set a context filter to include only breakfast products. Then you can create a top 10 filter by profit as a dependent filter, which would process only the data that passes through the context filter.

Note: As of Tableau 9.0, context filters no longer create temporary tables, except for generic ODBC data sources and customized data sources.

Create Context Filters

To create a context filter, select Add to Context from the context menu of an existing categorical filter. The context is computed once to generate the view. All other filters are then computed relative to the context. Context filters:

As shown below, the Ship Mode dimension is set to be the context for a view. The Region filter is computed using only the data that passes through Ship Mode.

You can modify a context filter by:

Speed up Context Filters

To improve performance of context filters, especially on large data sources, follow these general rules.

If your data set is heavily indexed, context filters may not provide performance improvement and may actually cause slower query performance.

Context filters can adversely affect any query performance improvements when using the Include joined tables only when referenced option in the Tables dialog box. See the note at the bottom of Join Your Data.

Example – Create Context Filters

This example walks you through how to create a context filter. First you’ll filter a view to show the top 10 products by sales. Then you’ll create a context filter on product category so you can see the top 10 furniture products.

  1. Use the Sample - Superstore data source to create the initial view shown below. The view shows the sales for all sub-categories, sorted with the highest sale at the top.

  2. Now create a Top 10 filter to just show the top selling products. You can create this filter by dragging the Sub-Category field to the Filters shelf. In the Filter dialog box, switch to the Top tab and define a filter that is Top 10 by Sum of Sales. See Filter Data from Your Views to learn more about defining a Top N filter.

  3. When you click OK, you’ll see that the view is filtered to show the top 10 product sub-categories in terms of sales.

  4. Now, let’s add another filter to show only furniture products. Drag the Category field to the Filters shelf and select only Furniture. When finished, click OK.

    The view is filtered but instead of 10 products, it now shows 3. This is because by default all filters are evaluated separately and the view shows the intersection of the results. So this view shows that three of the top 10 overall products are furniture products.

  5. To find out what the top 10 furniture products are we need to make the Category filter a context filter. Right-click the field on the Filters shelf and select Add to Context.

  6. The filter is marked as a context filter and the view updates to show the top four furniture products. Why not 10? Because only four of the sub-categories contain furniture. But we now know that the Top 10 filter is being evaluated on the results of that context.