Ever wondered what the following "Add to Context" option in Tableau is?

context option Tableau

How is this context filter different from a normal filter?
How does this affect the visualizations that I am building?

I will try to answer these questions as clear as possible in the sections below.

What is the difference between a filter and a context filter?

A normal filter works independently from the other filters and always looks at the entire dataset.
The image below shows this filtering process:

The context filter is higher in rank, so he goes first when it comes to filtering. This means he filters the entire dataset and gives the filtered result to the normal filter guys.
These normal filters can now work with the result dataset of the context filter.

The image below shows this clearly:

Context filter

I did not come up with this order that a context filter is executed before a normal filter by myself. This is the standard order of operations in Tableau.
The gif below shows the entire order of operations:

order of operations Tableau

Theory is nice, but how does it work in practice?

Well, let's say that I am interested in my top 10 customers by their sum of sales. Not only the global top 10 but for each segment separately.
We start off by showing the overall top 10 customers.

top 10

This seems to work fine. Now try to add a quick filter showing your different segments:

Quick filter in Tableau

When we try our quick filter, we see the data changing but we no longer have a top 10:

Quick filter in Tableau not working

Tableau looks at our top 10 and filters the customers who belong to the Home Office segment.
This is not the result we want. We would like to see 10 customers when we select the Home Office, meaning that Tableau needs to calculate something after we selected a filter value.

Right click in the filter shelf on Segment and select "Add to context".

Add to context

Now each filter option should always show 10 customer names!
This is because our Segment context filter is executed before a top 10 is calculated.

Are there additional benefits to a context filter?

Well yes, they also improve the performance in Tableau!
We are not going to dive into the performance part in this blog, in case you are interested please check the Tableau documentation here.


Timothy Vermeiren

Timothy Vermeiren

Analytics Domain Lead at Biztory, and DataDev Ambassador. Tableau Iron Viz 2018 Global Champion, Tableau Ambassador 2020-2021, Tableau Certified Consultant & Architect. He runs in his spare time & plays various musical instruments.

Read more articles of this author
Let's discuss your data challenges

Join our community of data enthusiasts

Get industry insights, expert tips and Biztory news sent straight to your inbox with our monthly newsletter.