Select Page

Hi everyone,

Today, we will talk about context filter and how it helps us in our analysis.

The first thing everyone needs to understand and have settled is the data filter priority in Tableau, in other words, how Tableau treats the filter priority behind the scenes in order to have the correct analysis.

Imagine the picture below is on a pyramid scheme. The extract filter will be at the top and the table calc filter at the bottom. The order of filter is from the top to the bottom. I will be using an Olympic data set for this example. The exercise consists of checking the top 10 countries by swimming sport.

### What are the steps?

The first thing to do is to apply the top 10 condition for countries as below:

After having set the filter, you should have the same view below:

However, we want to know the top 10 countries by swimming sport. Add sport on filters card and search for swimming:

At the first moment, you will have the same view below:

You might think it is correct, but it is not correct, and a good way to double check if it is correct or not is duplicating the sheet and remove “country” from “filters card”. It will show the correct countries.

We can clear see there is a difference between both pictures, right.

#### What should we do?

In this case to have the correct answer, we need to add the sport: swimming in context. So, Tableau will operate in the correct way, and giving you the correct answer.

note: you will notice the “sport: swimming” is in grey colour. Which means this dimension is being treated as a context.

Note: if you noticed, I highlighted 2 countries on my process of checking: South Africa and Great Britain. However, on my final viz, just Great Britain is showing up. Do you know why? it is happening because Tableau is ordering by Alphabetic order. So, G comes first.

Tip: If you are in doubt if you got the correct answer applying the context filter or not. Always double-check. It is better to spend 5 more minutes double checking than delivering a wrong answer. In Brazil there is an expression I will try to translate to English: “Insurance died of old.”, Well, I think the correct phrase English might be: “An ounce of prevention is worth a pound of cure.”