How To Show/Hide a Measure Filter with Sheet Swapping

In the essence of sharing knowledge, I wanted to share a way that I got around a problem I was having with a dashboard at work. For this post, I’ll be using the Sample Superstore data source that comes with Tableau. I’ve attempted to isolate and replicate my issues as closely as possible.

The Problem

In a dashboard that I’m building for a client, we are utilizing parameter swapping pretty extensively. I have two parameters:

  • What do you want to analyze?
    • This is the sheet swapping element. Users can swap between analyzing:
      • Geographic Variation
      • Sub-Category
  • View By:
    • This parameter allows the user to swap the measures being analyzed
      • Sales
      • Profit

Up to this point, this pretty straightforward/standard Tableau parameter work. If you’d like to or need to learn how to do that feel free to download my workbook and reverse engineer it to your needs.

But my problem came when I went to create the dashboard. Dashboarding best practices requires that you show the user a legend for any measure that’s being encoded. This means that when we put a measure on color to create a sequential or diverging color scale, we have to show the legend (if we don’t show the min/max values of the domain in a different way).

Consider the following:


This looks great. We have sales on color and we can see the measure filter on the right to show the color scale.

But what happens when the users what to analyze something else? And that on the next view DOES NOT have the measure on color


Oh man, this is not good. Now, that legend starts to get confusing to new users. There are many ways that I COULD do this:

  • put sales on color for the bar chart as well
    • Yep, I could do that but what if I have multiple different bar charts on this dashboard as well? Would I need to put sales on color for every bar chart in my dashboard?
  • Get rid of the legend all together all together and label the min & max values on both the bar chart AND the map
    • Another good option but, depending on all the other things on the dashboard, my data:ink ratio would start to get compromised a bit.

What I’d really like to do is have the legend hide away with the sheet when I swap away from it. For my situation, that would be ideal.

After some trial and error, I figured it out. I created a sheet that resembles a legend which allows me to utilize the parameter filter to show and hide different sheets. Check out the gif below that I created to see and click to see the workbook itself.

So how did I do it? It’s much simpler than it looks.

  1. I start by duplicating the worksheet with the map.
  2. Use “Show Me” to quickly change the worksheet to bar chart stacked bar chart
  3. I use the Ctrl+W keyboard shortcut. This swaps rows and columns
  4. Ctrl+click and drag my Measure field to color
  5. Right click on my dimension on the detail shelf and select “Sort”
  6. Sort descending the measure on color
  7. Click the “Label” card and select to show only Min/Max Values
  8. Now just remove borders and gridlines and the heavy lifting is complete

One thing that I noticed when I put it on the dashboard is the axis needs some attention because the labels get squished into the line making the values difficult to read. I used some table calcs and reference lines to get around that.

I hope you learned a little something today

Until next time!


Leave A Reply

Your email address will not be published. Required fields are marked *