In Tableau, filters play a very important role in analyzing and visualizing data. When working with dashboards, we often apply multiple filters to get specific results.
However, the output may not be as expected because Tableau processes filters in a specific order. This is where context filters become very useful.
A context filter in Tableau is a special type of filter that helps control how other filters are applied. It allows you to create a data subset first and then apply additional filters on top of it.
This concept is particularly important when working with large datasets, using Top N filters, or building complex dashboards.
Recently, I analyzed sales data across various product categories using a bar chart. In this, I implemented a filter in the subcategory to show the top 5 records with the highest sales.
In this, I also used the Category filter to exclude subcategory sales from their parent category. For example, I applied a Top N filter to show the Top 5 Sub-Categories by Sales.
Then I used another filter on the Category (e.g., removing Furniture), and the chart showed only 3 Subcategories instead of 5.
The records were displayed like this because Tableau first calculates the top 5 records, then applies the Category filter after the calculation. That means it is removing the records from the filtered top records.
In this case, I needed a solution that allows me to apply a Category filter and calculate the top N records. In Tableau, it was possible to use the Context filters.
In this Tableau tutorial, I will explain context filters in Tableau and how to use them in Tableau worksheets.