Have you ever been frustrated by getting unwanted result from Tableau filters? Count me in and follow me along as you may not know about Context Filter.

Dataset used in this blog: (you can download and explore it by yourself too)

https://drive.google.com/file/d/1rrb3efx08m4tN4FUFtzbu4JV3aUW0ETS/view?usp=share_link

Our desired output: to display top 10 sale people by sale for each region when we select a specific region.

This blog will explore how Tableau understands the order of filter when we add 2 dimension filters to the Filter Card.

Option 1: Just add needed filters

First, show the top 10 Sale person by Sale:

Add Region in Filter and show filter:

Notice how for region Central Tableau only shows 2 sale people? If you keep going you will see for East, there will be 7 sale people and for West there will be 1 sale person. That is the total of 10, our top 10 sale people by sale for the whole data set. This is because Tableau interpreted our command for filters as applying both filters simultaneously, to the entire data set. This has not met our goal of displaying top 10 sale people by sale for each region when we select a specific region.

Our desired output can be achieved if Tableau filter out the data set to each region first, and then filter out the top 10 sale people by their sale. There is an order of filters here that needs to be understood by Tableau.

Context filter is the answer here. Remember how in the previous blog, I have said Context filter can be used to force the order of filtering in Tableau.

Option 2: Using Context Filter

I recommend you duplicate the previous output sheet, and then apply context filter to region in the new sheet, so you could compare the results later on to understand the difference.

Now if you compare the result of each region to the previous output, you will notice the difference, for each region we have the top 10 sale people in that region displayed. If you also compare them to the top 10 sale people of the entire data set, you will see there are sale people who are not in the top 10 of all regions. We have successfully made Tableau understand the orders of filter that we want it to process, by using Context Filter.

In summary

Tableau reads: Apply both filters for me simultaneously.

Tableau reads: Apply Region filter first, then apply filter of Top 10 Sale people by Sale.

I hope this will help you to understand more about Context filter and to be able to achieve your desired output from Tableau filtering.

Thanks for reading. I would love to hear back from you about this blog, or anything data related really 😊.

Thao

Thao Phuong Tran
Author: Thao Phuong Tran

Thao is an experienced 3PL Warehouse Administrator and Retail Assistant Manager. Driven by a passion for data analytics and information technology, she takes pride in providing the best analysis to help businesses in making data driven decisions and tackling their issues. As a Data Analyst Consultant at The Data School, her goals include learning from the best people in the data industry and up skilling herself with relevant and powerful tools like Tableau, Alteryx, Power BI, etc. She adores applying process automation to improve her productivity and efficiency at work. When Thao is not keeping busy with data, you can find her enjoying collecting Pandora charms and baking chocolate mint cookies. She also loves dining out and a meal that never fails her is spicy Pad Thai paired with a Vodka Sunrise!