How to Make a Legend a Filter in Tableau

Cody Schneider9 min read

Showing a color legend on your Tableau dashboard is standard practice, but its default function is surprisingly limited - it only highlights marks, it doesn’t filter them. This article walks you through the simple yet powerful technique of using Dashboard Actions to transform your static color legend into a fully interactive filter, improving the user experience and making your dashboards much more dynamic.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Why Bother Turning a Legend into a Filter?

Before diving into the "how," let's quickly touch on the "why." While it might seem like a small tweak, making your legend a filter has several practical benefits that significantly improve your dashboards.

  • Better User Experience: People intuitively expect to click on a legend item and see the corresponding data. Highlight actions can be confusing because other marks are still visible, just faded. Filtering provides a clean, clear view of the selected data, matching user expectations.
  • Saves Prime Dashboard Real Estate: Many developers add a separate "Filter" card to their dashboards to filter the very same field the color legend represents. By making the legend do both jobs, you eliminate a redundant dropdown or list, freeing up valuable space for more important visualizations.
  • Creates a Central Control Panel: A single, well-placed interactive legend can serve as a simple control hub for your dashboard, allowing users to quickly cycle through different categories without needing to hunt for a separate filter control. It feels more cohesive and professionally designed.

The Default Behavior: Highlight vs. Filter

Let’s start by building a simple view to see what Tableau does out of the box. Imagine you're using the Sample - Superstore data set and you want to see sales for each Sub-Category, broken down by their main Category.

You would build a simple bar chart like this:

  1. Drag SUM(Sales) to the Columns shelf.
  2. Drag Sub-Category to the Rows shelf.
  3. Drag Category to the Color mark on the Marks card.

Your result is a bar chart showing various sub-categories, with bars colored blue for "Furniture," orange for "Office Supplies," and red for "Technology." Tableau automatically generates a color legend for the Category field.

Now, if you add this sheet to a dashboard and then click on "Technology" in the legend, you'll notice it simply highlights the Technology-related bars. The "Furniture" and "Office Supplies" bars don't disappear, they just fade into the background. This is useful in some contexts, but it's not filtering. Our goal is to make those other bars disappear completely.

To do that, we need to leverage one of Tableau's most powerful features: Dashboard Actions.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Step-by-Step Guide: Using a Filter Action

Dashboard Actions allow you to add interactivity between your sheets and even with elements outside your dashboard, like URLs. For this task, we will create a "Filter Action" that listens for a click on our chart and uses that click to filter the data.

Follow along with the bar chart we just created. First, make sure you've placed it on a new dashboard.

Step 1: Open the Dashboard Actions Menu

With your dashboard view open, navigate to the top menu and click Dashboard > Actions...

This opens the Actions dialog box. This is mission control for all the interactive elements on your dashboard. From here, click the Add Action > button and select Filter...

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Step 2: Configure the Filter Action

You’ll now see the "Add Filter Action" configuration window. It looks a bit intimidating at first, but it breaks down logically into a "source," an "action," and a "target." Let's walk through each setting.

1. Name the Action

Start by giving your action a descriptive name at the top. This is extremely helpful when you have multiple actions on a single dashboard, so you can easily identify what each one does later. Let’s call ours "Filter by Category Legend."

2. Define the Source Sheet

Under "Source Sheets," you tell Tableau which dashboard and which sheet(s) will trigger the action. In our simple example, we only have one dashboard and one sheet.

  • Ensure your current dashboard is checked.
  • Underneath, in the list of worksheets, make sure only your bar chart sheet is checked.

Why is this important? Because of a sneaky Tableau behavior: an action is triggered by clicking on a mark within the specified sheet. The color legend is not a separate object, it is directly tied to the sheet it belongs to. By selecting the sheet itself as the source, you're telling Tableau, "When someone clicks on the marks or its interactive legend for this sheet, I want to start an action."

3. Set the "Run Action On" Trigger

This setting determines how the user will activate the filter. You have three choices:

  • Hover: The action runs when a user simply moves their mouse over a mark or legend item. This can be very fast, but it can also be disruptive if the user is just trying to look at tooltips.
  • Select: The action runs when the user explicitly clicks a mark or legend item. This is the most common and predictable choice for filters.
  • Menu: The action adds an option to the tooltip menu. The user has to hover, wait for the tooltip, then click a hyperlink in the text. This is best for secondary, less-common actions.

For our purpose, Select is the clear winner. Let's use that.

4. Choose the Target Sheet(s)

The "Target Sheets" section determines which sheets will be affected by the action. Since we want to filter the same chart we're clicking, we will set the target to be the same as the source.

  • Make sure your dashboard is selected from the dropdown.
  • In the sheet list below, check the box for your bar chart sheet.

If you had multiple charts on your dashboard (e.g., a map, a line chart) that you also wanted to filter by category, you would check their boxes here as well. This is how you create fully interconnected dashboards.

5. Decide What Happens When You Clear the Selection

This is a crucial setting that dictates the dashboard's behavior after the filter is applied and then deselected. You have three options for "Clearing the selection will":

  • Leave the filter: When the user clicks away, the dashboard remains filtered on the last item they selected. This can be great for a "drill-down" analysis, but confusing if the user wants to get back to the full view.
  • Show all values: This is the most intuitive option. When the user clicks the selected item again or clicks in an empty space, the filter is removed and the dashboard returns to its initial, unfiltered state.
  • Exclude all values: When the user deselects, everything on the target sheet disappears. This is useful in very specific "show/hide" container situations but is generally not what you want for a simple legend filter.

Let's choose Show all values for a natural, user-friendly experience.

6. Specify the Target Filters

Finally, under the "Target Filters" section, you tell Tableau which field to filter on. You want to filter based on the field that defines the color legend - in our case, the Category field.

  • Make sure Selected Fields is chosen.
  • You should see a prompt to add a filter. Click Add Filter... if one isn't already present.
  • In the "Add Filter Field" dialog, ensure the Source Field (from our bar chart sheet) is set to Category and the Target Field is also set to Category. This tells Tableau, "When a user clicks on something representing a Category in the source, filter the target to only that Category."

Click OK twice to close both the "Add Filter Action" window and the "Actions" window.

Step 3: Test Your New Interactive Legend

Now for the fun part. Go back to your dashboard and click on "Technology" in the color legend. Voilà! All the other bars instantly disappear, leaving you with a clean view of only the Technology sub-category sales. Click on "Technology" again (or in the blank chart area), and everything returns to normal.

You have successfully turned your legend into a filter. You've gotten rid of the default highlight action and replaced it with a much more powerful filter action, making your dashboard cleaner and more intuitive in just a few clicks.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Advanced Tip: The "Legend Sheet" Technique

While the method above works perfectly, advanced users sometimes prefer even more control over the look and feel of their legends. One popular technique is to create a separate worksheet whose only job is to act as a custom legend and filter trigger.

For example, you could create a new sheet with:

  • Category on the Rows shelf.
  • Category on the Color mark.
  • Change the mark type to Square.

This creates three colored squares, one for each category. You can then add this sheet to your dashboard, hide its title, and position it where you'd want a legend to be. Now, you can point your Dashboard Action to this "Legend Sheet" as the source and your main chart(s) as the target. The benefit is more formatting control - you can customize labels, sizes, and layout in ways that the default legend doesn't allow.

Final Thoughts

Transforming a legend from a highlighter to an interactive filter is a cornerstone skill for building user-friendly Tableau dashboards. By mastering Dashboard Actions, you can eliminate clutter, follow user experience best practices, and create dynamic reports that empower people to explore data on their own terms.

Building interactive dashboards from scratch in tools like Tableau is a powerful skill, but it often involves a steep learning curve and many steps - just like creating that single filter action. At Graphed, we automate the entire process. Instead of navigating menus and configuring actions, you can simply describe the dashboard you need in plain English - like "Show me our sales by sub-category, color-coded by category" - and get a real-time, interactive dashboard in seconds. We connect directly to your data sources, so you get the insights without the setup headache.

Related Articles