Multi-Chart Swapper in Tableau (Dynamic Zones #2)

Too many charts, too little dashboard space? In today’s post, the first in my series about use cases for Tableau’s Dynamic Zone Visibility, we’ll look at how to swap between multiple charts with a single parameter. (New to dynamic zones? Start here)

Why Swap Charts?

Swapping charts allows you to use the same area of the dashboard to show multiple different visual perspectives. I especially like using a chart swapper when I want to represent the same data in a couple different ways to account for different users’ needs.

Some people might be best served by seeing data as a map, some as a bar chart, and some just need to see the numbers. Using a chart swapper gives users options without taking up the whole dashboard.

However, make sure you don’t fall into the trap of over-using sheet swappers to cram too much onto your dashboard! If the charts you’re swapping show totally different things, or it gets hard for users to find the information they need, it’s not the right option.

With that in mind, let’s look at how to set up a three-chart swapper that you can easily expand and modify to fit your needs.

Step 1: Make Your Charts

The chart swapper works by changing the visibility of worksheets on the dashboard. To get started, create each chart you want to use as separate sheets in your workbook. In my example, using the superstore data set, I’ve created a “Map View”, “Table View”, and “Chart View” that all represent the same set of sales data by state.

As always, you can head to Tableau Public to get a downloadable version of the example workbook.

Step 2: Add the Charts to a Dashboard

Next, add all of the sheets you just created to your dashboard.

I like to put all the charts into a single horizontal or vertical container (as shown in the example), which can be either tiled or floating. Once your swapper is set up, you’ll be able to interact with that container to change the position, size, etc of all the charts at once, almost like they’re just one object. It’s a nice clean way of organizing a swapper.

The alternative is to make all of the individual charts float in the same spot on the dashboard – if you choose this option, you’ll have to change each chart individually if you want to adjust size or position later on.

Step 3: Create a Parameter

Now we can create the parameter that we’ll use to swap between the charts. Head back to a worksheet and add a new parameter.

Name your parameter something obvious – I’ve called mine “2: View Type”. (The “2” refers to the dashboard this parameter is being used on). Set your data type, change your allowable values to “list”, and enter in the different options for the swapper.

I usually use a string data type, because it’s the easiest to interpret and remember for the calculated fields later.

Step 4: Make Boolean Calculated Fields

The problem with the parameter we just created is that it doesn’t fit the criteria for a dynamic zone visibility control, because it isn’t Boolean. (That is, its values aren’t just “True” and “False). Let’s fix that!

You’ll need one calculated field for each chart you want to include in your swapper. I’ll start with making a calculated field that will show the map view.

This field will return “True” if the “2: View Type” parameter is set to “Map”. The rest of the time, it’ll return false. That’s exactly what we want for our dynamic zone! If “Map” is selected, the map zone should show. The rest of the time, it will be hidden.

Go ahead and create calculated fields for your other charts in the same way.

Step 5: Add Dynamic Zone Visibility

Now let’s make these charts dynamic! Back on the dashboard, select one of the charts. (I’m still working with the map here). Check the “Control visibility using value” box in the layout pane, and select the calculated field you created for the chart.

Notice that we’re now looking in the data fields to find the controller, not in parameters. The calculated field we created is what’s directly controlling the map’s visibility, so that’s the field we need to use.

(If you’ve already added your other calculated fields, you’ll see multiple options here – choose the one that matches the chart you have selected)

Repeat this process for the other charts in your swapper. As you set up dynamic zone visibility, you’ll see some of your charts disappear. Don’t panic! This is exactly what we want to happen – only one chart will be visible at a time.

Step 6: Add a Controller

Finally, let’s give the user something to interact with on the dashboard to swap the sheets.

Click the options arrow on the visible chart, and add the parameter we created in step 3.

Move the parameter to your preferred location and we’re done! Changing the parameter will change which chart is shown.

Bonus: Add a Dynamic Legend

To take this chart swapper to the next level, let’s add a color legend. I only want the legend to appear when the map is being shown.

Change the view type so that the map is shown, and then add a legend using the options arrow. I like to make the legend float over the map, but you could keep it tiled if you prefer.

Now click the legend and go back to the layout pane on the left side of the screen.

Check the “Control visibility using value” box, and select the same calculated field that shows the map.

That’s it! You now have a legend that will only appear when the map is shown. This isn’t only useful for legends, though – you could use it for a text box, filter, image, link, or any other object.

More Reading

If you want to get extra-fancy, you could use icons to change the parameter instead of a default parameter control. Check out this post to learn how!

Before you go, make sure to subscribe in the side bar to get notified when I add new use cases for dynamic zone visibility to the series. Happy vizzing!

Let's keep in touch! New tips, tricks, and tutorials are posted about once a week - sign up to get them straight to your inbox!

I don’t spam! Read the privacy policy for more info.

One thought on “Multi-Chart Swapper in Tableau (Dynamic Zones #2)

Leave a Reply

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