Tableau - Context Filters


The normal filters in Tableau are independent of each other. It means each of the filter reads all the rows from the source data and creates its own result. However, there may be scenarios where you might want the second filter to process only the records returned by the first filter. In such a case, the second filter is known as dependent filters because they process only the data that passes through the context filter. Context Filters serve two main purposes.

  • Improves performance − If you set a lot of filters or have a large data source, the queries can be slow. You can set one or more context filters to improve the performance.

  • Creates a dependent numerical or top N filter − You can set a context filter to include only the data of interest, and then set a numerical or a top N filter.

Creating Context Filter

Using the Sample-superstore, find the top 10 Sub-Category of products for the category called Furniture. To achieve this objective, following are the steps.

Step 1 − Drag the dimension Sub-Category to the Rows shelf and the measure Sales to the Columns Shelf. Choose the horizontal bar chart as the chart type. Drag the dimension Sub-Category again to the Filters shelf. You will get the following chart.

context filter 1

Step 2 − Right-click on the field Sub-Category in the filter shelf and go the fourth tab named Top. Choose the option by field. From the next drop-down, choose the option Top 10 by Sales Sum as shown in the following screenshot.

context filter 2

Step 3 − Drag the dimension Category to the filter shelf. Right-click to edit and under the general tab choose Furniture from the list. As you can see the result shows three subcategory of products.

context filter 3

Step 4 − Right-click the Category: Furniture filter and select the option Add to Context. This produces the final result, which shows the subcategory of products from the category Furniture which are among the top 10 subcategories across all the products.

context filter 4