We learned Level of Detail (LOD) in Tableau before Christmas holiday. During the whole training, Peter, our trainer, kept strengthening the importance of ORDER OF OPERATIONS (Click for more info). Because I want to figure out what each operation represents, I did some research at home. This blog is mainly about one of the operations – Context Filter.

Normally, filters in Tableau are considered independent filters. However, when we edit one filter as context filter (which is still an independent filter), other filters will only process the data filtered out by the context filter, making them dependent filters.

It has two major advantages: improve performance and create a dependent numerical or top N filters. Take Super Store data set as an example. Our goal is to find out the top 5 subcategories by sales. I filter out the top 5 subcategories by sales, like in the photo below. We can find that chairs, copiers, bookcases, phones, and appliances are in the list.

 

 

Advantage 1: create a dependent numerical or top N filters

 

One may ask – you already filter out the top 5 subcategories already, why should you use context filter? The thing is, if I didn’t use context filter and finished by what I did in the first step, once I deselect Technology from category filter, my subcategories will only end up with 3 categories like the photo below.

 

 

With the help of context filter, no matter what I deselect from category, it will always have 5 highest subcategories by sales in my sheet. Therefore, subcategory has become the dependent filter of the category filter.

Create context filter by right clicking category in Filters and select Add to Context, and the blue pill will become grey.

 

 

Advantage 2: improve performance

 

To make the worksheet more user friendly and decrease the size of the worksheet, we can also change the dependent filter to only show relevant value. In this case, subcategory filter will only show subcategories belongs to Furniture and Office Supplies.

 

Ivy Yin
Author: Ivy Yin