Context Filters in Tableau Desktop

In the realm of data visualization, the ability to derive meaningful insights from raw data is paramount. Tableau Desktop, a powerful and versatile data visualization tool, offers a plethora of features to achieve this goal. One such feature that significantly enhances the analytical capabilities of Tableau is the use of context filters.

Context filters in Tableau Desktop allow users to refine the data being analyzed by creating a subset of the original dataset. This is accomplished by isolating specific dimensions or measures relevant to the analysis, thus focusing on the essential elements for a particular visualization. The key advantage of employing context filters lies in their ability to improve performance by reducing the dataset size, consequently making visualizations load faster and computations run more efficiently.

When using context filters, Tableau processes the data in two stages. First, it retrieves the subset of data based on the context filter, and then it applies subsequent filters and computations within this filtered context. This sequential processing ensures that the visualizations reflect the desired analysis accurately.

For instance, consider the Superstore dataset which contains sales information across multiple regions and product categories. By setting context filters for a specific region or product category, you can focus on analyzing and visualizing the sales trends and patterns for just that segment of the data.

Let’s how that looks in Tableau Desktop:

1. Using the Sample - Superstore data source I created the initial view below. The view shows the sales for all sub-categories, sorted with the highest sales at the top.

2. I then created a Top 5 filter to show the top-selling sub-category products.

This filter is created by dragging the Sub-Category field to the Filters shelf. In the Filter dialog box, I selected the Top tab and modified the filter so that it states top 5 by Sum of Sales.

3. After I applied Filter, the view is now filtered to show the top 5 product sub-categories for sales.

4. I then added another Filter to show only Sub-Category products for the Office Supplies products. I dragged the Category field to the Filters shelf and selected only Office Supplies.

This filtered the view however it only shows 2 Sub-Category products instead of the intended 5. Tableau is behaving in this way because by default each filter is applied separately and the view shows the intersection of each filter applied. Simply put, the view shows that 2 of the top 5 overall products are Office Supplies products.

5. Now I need to find out what the top 5 Office Supplies products are, so I need to modify the Category filter to create a context filter. I right-click the “ Category: Office Supplies” field on the Filters shelf and select Add to Context.

The filter is now marked as a context filter and the view updates to show the top 5 office supplies Sub-Category products. Now that I have made this modification the top 5 filter is being evaluated on the results of the context filter I have applied.

Context filters in Tableau Desktop are a fundamental tool for enhancing data visualization by refining and isolating specific data segments. Utilizing context filters not only improves performance but also facilitates a deeper understanding of the data, leading to more insightful and accurate visualizations.

Michael Bellamy
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab