Context Filters: What Are They?

by Gerda Staurylaite

Whilst covering the fundamentals of Tableau, we have come across some filters, and in particular, the context filters.

There is a certain order that Tableau follows when doing any of these operations. As we are focusing on the filters, we can see the order of the operations for filters in the photo below.

The beginning of Order of Operations in Tableau

A context filter is applied before any other filter other than extract filters. Applying context filters are useful because that way you can manipulate the data to make sure it is giving the answer to the question you have got.

Essentially, when we are working with multiple filters, we can run into few problems that might not give the results we would like to get.

For example, using the Superstore dataset, we want to see the top 5 most profitable states in a particular region.

We set out our Tableau sheet, using State for the rows and Profit for the columns and sorted our data in descending order.

Adding and sorting the data

Then, we would add the Region in the marks pane and with colours so that we can see the states in different regions. After that, we would have to add a filter to choose top 5 most profitable states.

To create a filter, we would drag State to the filters pane and then configure it by using all the states and then clicking on the Top button at the top and picking top 5 states by profit. This is shown below:

Creating a filter

This is what we would get as the result, where the region is highlighted by the colours and the states are filtered:

Then, we will add the next filter to make sure we see Top 5 for a particular region (which we picked to be West):

Applied the two filters that we have

The issue here is that even though we picked top 5, it is only showing top 2 states. This is due to the order of operations. Here is where the context filters come in. We have to use the context filter here to get thew top 5 profitable states of the West region. So what we have to do is to change the region filter to a context filter and then we will get the desired result.

How to add the filter to context
The desired result

At the end the context filter turns grey!

This is how you get the desired result, which was top 5 profitable states in a particular region and in this case it being the West region.

Thu 27 Oct 2022

Tue 25 Oct 2022