Tableau Context Filters
All filters that you arrange in Tableau are computed independently. And, each filter accesses all rows in your data source without view to other filters.
You can arrange one or more categorical filters as context filters for the view. And context filter can work as an independent filter. Any other filters that you arrange are defined as dependent filters because they process only the data that passes through the context filter.
Context filter is created because of the following reasons:
- Improve Performance: If you want to set a lot of filters or have a significant data source, then queries start running slowly. In such case, you can set one or more context filters to improve performance.
- Create a Dependent Numerical or Top N Filter: You can set a context filter to include the data of interest only, and arrange a numerical or a top N filter.
Create a Context Filter
To create a context filter, first select Add to Context from the context menu of an existing categorical filter. The context is computed once the view is generated. All other filters are then calculated relative to the context. Context filters are:
- Appeared on the top of the filters pane.
- Identified by the gray color on the filters pane.
- Not rearranged on the filters pane.
For example , consider the data source such as Sample-superstore , find the top 10 Subcategory of products for the category called Furniture . There are the following steps.
Step1: Drag the Sub-Category field to the Rows shelf and Sales field to the Columns Shelf.
Step2: And, choose the horizontal bar chart from the " Show Me " tab.
Step3: Again, drag the Sub-Category to the Filters shelf. You get the chart shown in the below screenshot.
Step4: Right-click on the Sub-Category field in the filter shelf and click on " Edit Filter " option then go the " Top " tab in the pop-up window.
Step5: And, choose the " By field " option. From the next drop-down, choose the option Top 10 by Sales Sum as shown in the below screenshot.
Step6: Drag the Category field to the filter shelf. Right-click on the Category field to edit and choose Furniture from the list. It shows three subcategories of products as a result shown in below screenshot.
Step7: Now, adding the context filter, Right-click on the Category: Furniture filter and select the " Add to Context " option.
Step8: Above all steps produce the final result that shows the subcategory of products from the category Furniture.