Tableau: Context Filter With its Use Case

Filters have meaning: Context filter is best out of that

Laxman Singh
May 1 · 5 min read

Tableau is the new generation visualization tool. I consider it as most easiest one to implement visualization for your audience. It has several features to distinguish it from other existing tools. It is capable of handling all sort of problems for representing data in different format.

Tableau is capable of achieving smart task in smart way. Better to learn and master them

There are certain problems which can’t be handled directly. Or, I would say you have to tweak the current features to achieve your requirement. Here, I will explain you how can we handle the requirement where we want data to be filtered on the fly and will give flexibility to have different data to be displayed in different sheets. In fact, you can allow user to choose the values and then it will apply other rules on top of that to show the final visualization. And, answer is context filter. This filter is really different from other types of filter and able to solve real-time problems with ease. Eg, let us suppose you want to see top 5 categories in the data. It is easy to implement. Later on, you want another category to be given to user to select and show top 5 categories as per selection. Context filter provides this facility with some advantages and drawbacks. Let us discuss and conquer this.

Context Filter

In general, tableau has filters which are computed independently. Here, independently means one by one. Let us assume you have two filters on country and state. You select one country and select other state. Both filters will bring the data based on the whole data and works independently. There is no dependency and in real-world scenarios, most of the time it is not applicable.

In simple, Context filter allows you to apply on the data at runtime. Once the options are exposed to user, user can select the filter and visualization will change accordingly. In case you have other filters, that will get applied after applying context filter.

Context filters are filters on which other filters will be dependent.

Dependent filters mean they will process the data which is already filtered by context filters. Not like in normal case where they apply on the whole data.

There are some advantages because of context filters:
1. performance improvement : It is applied at sheet level and not at query level so it can definitely help.
2. Flexibility : Only data at 1 sheet will be changed and other sheets can still make use of the whole data
3. Top N items: It is the best use case where context filters can be used more effectively.

About the Dataset

I have created my own data set specifically for this example. It has three columns: country , state and count. I have taken 5 countries and their respective state. Idea is to achieve top n counts for the country selected.

Difficulties

Once we have created our sheet to display top 4 count based on state and keeping country as filter. If we apply normal filters and select any specific country, it might not show data if no state is appearing for that country in top 4. Indirectly, it is due to normal filter and they are independent to apply on whole data. Due to which they are having top 4 as final output and once you apply country filter, it will show only once it appears in overall top 4. This will give wrong visualization.

Solution

Create country filter as context filter and then once you select any country, it will show the top 4 state for that country. This will effectively solve the problem for you. Now, question comes how can we make normal filter to context filter. It’s tableau. Definitely, answer will be hidden in one click and selecting the option.

Correct, we can just click on the filter in filter shelf to select “Add to Context” option and then show filter.

Converting normal filter to Context filter

Once you have selected the above option and show filter, it will start appearing in the right hand corner to be selected. In my case, it is as below:

Filters for country at right- with Select all option

For selecting all, it will show the top 4 in all the countries. And, you will have top 5 for all countries in the data.

If I select only 1 or 2 country, visualization will start changing based on that and will show top 4 count for selected countries. Amazingly beautiful and easy.

Finally, we are able to solve our problem with context filter. And, creating context filter is just one click task. Beauty of technology and visualization tools.

Conclusion

Tableau has many filter options. You can filter at any stage of data processing. Context filter is one of the important filters to learn which is capable of providing performance gain along with flexibility. This is as simple as one click and achieving the best of the visualization results. Context filters are must to have in your knowledge buckets and I hope this will help to solve your real-time problems more effectively. Happy learning and Coding!

Geek Culture

Proud to geek out.

Sign up for Geek Culture Hits

By Geek Culture

Subscribe to receive top 10 most read stories of Geek Culture — delivered straight into your inbox, once a week. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Laxman Singh

Written by

Machine Learning Engineer | Data Science | MTECH NUS, Singapore

Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Laxman Singh

Written by

Machine Learning Engineer | Data Science | MTECH NUS, Singapore

Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store