Context Filters & Tableau's Order of Operations

by Michael Bracchi

When covering the fundamentals of Tableau Desktop, one concept that jumped right out at me was context filters. I have spent only a little time with Tableau but would have already benefited a lot from understanding this earlier. So…. ask the community for help!!! I don’t intend to look at Tableau’s full order of operations, only how it relates to context filters. For details check out Tableau’s help page:

In This Post:

  • WHAT is a context filter and how is it different to a normal filter
  • HOW to apply/remove a context filter?
  • WHEN & WHY use a context filter?

What is a Context Filter?

So…. By default, when a view has multiple filters applied to it, all filters are applied to each row in your data set and are ‘independent’ of each other. These filters are blue/green in the filter shelf and are formed by dragging and dropping a field into the filter shelf or by right-clicking a field in the data pane and hitting ‘show filter’. Easy.

According to Tableau’s order of operations (see below), a context filter is applied before any other filter type other than extract and data source filters.

This order means that when we have one or more context filters in a view
any other filters used in that same view are applied only to rows which make it through the context filter. It helps me to think of them as ‘dependant’ on the context filter.

How do I Apply a Context Filter?

Forming context filters is easy as right-clicking the desired field in the filter shelf and hitting ‘Add to context.’ This turns a from blue to grey. Continuous filters cannot be used as context filters.

When and Why Use a Context Filter?

In the below example, using the US-Superstore data, a view is set up showing the 10 least profitable products in a dynamic set (coloured blue). No matter which region/category boxes are ticked/unticked in the filter panes (red boxes) the set remains updated and always shows the 10 least profitable products highlighted blue. Notice that both region and category filters are context filters.

If either category or region filters are removed from context, the dynamic filter fails to return the top 10 least profitable products. In the below screen shot only 6 products are highlighted, this is because the category filter is filtering out some of the 10 least profitable products and they are not shown in the view. The coloured top 10 does not dynamically adjust.

A Second Example:

The view below shows top 10 products by total sales. The ‘Sub-Category’ filter is set as a context filter (its grey), so, this means that ‘Sub-Category’ filtering occurs before the top 10 ‘Product Name’ filtering. This is because the top 10 ‘Product Name’ filter is a dimension filter, hence, its blue colour in the filter pane. In this case, the top 10 by sales dynamically updates to incorporate whichever products are in the current top 10, after the application of the sub-category filter.

There it is, a brief run through of context filters demonstrated by their importance in making dynamic sets.

Further Reading:

For more information on order of operations relating to sorting within filters check out this great blog post by Ellie Mason of DS11:

and this post by Joe Macari, linking order of operations to table calcs and LODs:


Michael Bracchi

Fri 23 Aug 2019

Wed 21 Aug 2019

Tue 20 Aug 2019

Mon 19 Aug 2019