Filters in General

There are six major types of filters that are available in Tableau. These filters are namely, extract filters, data source filters, context filters, dimension filters, measure filters, table calculation filters. In Tableau, these filters are applied in an specific order as predefined by Tableau which is called as order of operations.

 

Context Filters in General

When multiple filters are applied to your worksheet, it might not always give the results as you expected. This is because the filter you think is acting first might not be filtering first. Rather another filter among all the filters applied to that worksheet and is up in the hierarchical level in order of operations will precede. Here the importance of context filters comes into play. Context filter comes right after extract filters and data source filters in hierarchy followed by rest of the filters. So if you add your preferred filter to context, it will act first followed by rest of the filters, which solves your issue. Let us understand context filters using an example.

Understanding Using an Example

Say we are using sample superstore dataset and I built a chart showing profit by states and region.

Here, if we filter top 5 states, we will get this result below.

Lets say we want to built a chart that shows top 5 states by Profit for Central and West Regions only. So, we applied Region filter and only selected West and Central regions.

We expected to see top 5 states in Central and West Regions. But instead of top 5 states in Central and West Region, top N filter (in our case top 5 states overall) has preceded the dimension filter as per the order of operations. So what Tableau is doing is filtering top 5 states overall. Out of that top 5 states overall that are filtered, it is then applying the region filter. There are only 3 states from Central and West region in top 5 states overall by profit. which we get as a result.

To fix this, let us add Region filter to context. To do that, just right click on Region filter and select ‘add to context’.

There are two important things that we notice here. First, region pill color in the filter shelf changes to grey color. This signifies that context filter is applied. Also, now we see top 5 states that belong to only Central and West region.
Lets understand what exactly happened. As context filter is above top N filter category in hierarchy as per order of operation, so first only states in South and East region will get filtered and from the pool of the Central and West region, top 5 states by profit filter will apply and give us top 5 states.

What we discussed

We have discussed about the context filters and its application which is one of the most important concept around application of filters. What I tried to explain here is that in a worksheet with multiple filters, by adding any specific filter to context, it will precede other filters due to its hierarchal position in the order of operations, i.e., your chosen filter that is added to context will apply first and followed by other filters. I hope this blog has helped you building your concept around context filter better. Thank you for ready my blog.

Vaibhav Patel
Author: Vaibhav Patel