How to use context filters in Tableau Desktop?

Preparation time: 5 minutes

Level of difficulty: Easy

Objective: Understanding context filters

Context filters in Tableau allow you to organize your analyses hierarchically, a crucial function when it comes to creating accurate rankings.

By default, all filters in Tableau are applied independently, meaning they don't take into account other active filters. So, if you want to, for example, show the top 10 subcategories in a specific category, classic filters do not allow you to do this directly.

Context filters solve this problem by allowing you to set a priority. : you can filter by category first, then get a precise ranking of the sub-categories within this selection. A bit like prefiltering data before normal filters.

The order of operations in Tableau. We can see that the context filters are above the dimension filters.

Required Data

  • 1 data set, Hypermarket (at the bottom of the Tableau Desktop login page),
  • 1 measure, for example sales,
  • 1 dimension, such as Sub-categories.

Step 1: Building a chart

  • Drag the dimension Sub-category In the Lines,
  • Drag the measure sales In the Columns.

Step 2: Understand how filters work

  • Add a filter to show the Top 10 Of Sub-category by the sum of Sales,
  • Add a filter on the field Category and select a single category, for example Supplies.

The view is filtered, but only 3 products are shown instead of the expected 10. This is because, by default, each filter is evaluated independently, and the view only shows the intersection of the results. So this view shows the three of the ten top-selling products that are in the Office Supply category.

To display the top 10 sales by sub-category for a given category we will use a context filter.

Step 3: Add a context filter

  • Right click on the filter Category and select Add to context.

The view now shows the Top 10 sellers by subcategory for the Office Supply category.

Advice

Don't overuse context filters. Excessive use of them can increase performance and introduce unnecessary complexity. Use them in a targeted manner, and only when a clear filtering hierarchy is needed or performance gains are expected.