Understanding Tableau Context Filters

Context filters in Tableau are a big mystery right? In this video I will demonstrate two examples that will help shed some light on how context filters in Tableau work.

When I was starting to learn Tableau, I had no idea why I would ever need to add a filter to the context. It just didn’t make sense for me, because most of the time, the filter still operated in a manner I expected. Little did I know, I was moving a filter on up, to a deluxe apartment in the sky!

That is because I did not understand Tableau’s order of operations. This understanding is key. The higher the filter is on the official order of operations skyscraper, the more influence it has on all the other filters below it.

When two dimension filters are applied to a visual, they are working independently with access to all rows in the data source without regard to other filters. Eventually the filters decide what values they have in common (i.e., the intersection), and those values are shown on a visual.

But if you change your dimension filter to a context filter, you’ve ensured that any other filters that you set are defined as dependent filters because they process only the data that passes through the context filter.

This concept will be very handy when trying to compute the Top N values. Notice on the order of operations that Top N is located below context filters. That means that the Top N filter will only receive values that have been “pre-filtered” from the context filter.

What’s in it for You?

Per Tableau, use context filters to:

  • Improve performance – If you set a lot of filters or have a large data source, the queries can be slow. You can set one or more context filters to improve performance.
  • Create a dependent numerical or Top N filter – You can set a context filter to include only the data of interest, and then set a numerical or a top N filter.

To improve performance of context filters, especially on large data sources, follow these general rules.

  • Using a single context filter that significantly reduces the size of the data set is much better than applying many context filters.
  • In fact, if a filter does not reduce the size of the data set by one-tenth or more, it is actually worse to add it to the context because of the performance cost of computing the context.

Still scratching your head? It will all make sense after the video examples. Give it a watch!

Of course, check out the official documentation from Tableau where I sourced these tips.

All views and opinions are solely my own and do NOT necessarily reflect those my employer.

Do Great Things With Your Data

-Anthony B. Smoak

Photo by Andrea Piacquadio from Pexels