Creating Dynamic Color Legends for Worksheet Swaps

By: Eric Parker

Pro Headshot.jpg

Eric Parker lives in Seattle and has been teaching Tableau and Alteryx for 5 years. He's helped thousands of students solve their most pressing problems. If you have a question, feel free to reach out to him directly via email.

After creating a parameter that lets you swap worksheets in a Tableau dashboard, one of the problems is that when a worksheet goes blank (because it is swapped away from), the color legends associated with that worksheet also temporarily go blank.

Let’s use this simplified example from the previous section as our test case. Notice how when the map is showing, the color legend below the maps displays well:

118-1.png

Here’s what happens when the visual is switched to display the bar chart:

118-2.png

Not as good of a look. Additionally, notice the different dimensions being used. On the “Map” view, the State field is the most granular dimension. On the “Bar Chart” view, Customer Name is the most granular dimension.

This poses another problem because this is what the map color legend should look like:

 
118-3.png
 

And this is what the bar chart color legend should look like:

 
118-4.png
 

Notice those ranges are drastically different.

The solution is to create a third worksheet that doesn’t get swapped out. The first step is to create a field that switches the dimension to match either the “State” or “Customer Name” level of granularity.

 
118-5.png
 

The next step is to create a worksheet using that field that automatically adjusts based on what is selected in the parameter.

118-6.png

Finally, you float the color legend worksheet in the dashboard (and eventually make it so small it’s unnoticeable). At the same time you want to replace the old color legend with the new one.

118-7.png

With this new setup it doesn’t matter what is selected in the parameter, the range of the color legend will reflect the data range on the worksheet that’s displaying and be dynamic.

118-8.png

Notice how the range is different between the two previous images.

Need help with your own visuals? Sign up for an office hour and we can tackle them together.

Should I choose a centralized or decentralized model of Tableau deployment?

Grouping Options in Tableau

0