Swap Charts with a Parameter

For a recent visualisation I created for the #30DayMapChallenge, I wanted the focus to be the map so the view was zoomed in such that the map took up most of the screen.  However, I still wanted the option to view three charts to provide further insights if the viewer was interested to see those.

One option was to display all three charts in a pop-up, collapsible container, however, they would then obscure the map in the background, which is a problem in this case as there are highlight actions to highlight the marks in the view corresponding to each bar in the charts.

Sheet Swapping

Instead, as there was space for one chart, I decided to show one at a time and allow the viewer to change the visible chart to another one as needed. This is not a new technique and is something I use often but I haven’t set it up with this specific configuration of the user interface (UI) before.

Usually, I use a drop down list or custom buttons with parameter actions but in this case I wanted a minimal UI and only wanted to show the left and right arrow parameter buttons so the viewer can cycle through charts. I chose to use the standard parameter buttons for a faster response and to make the build simpler.

This is the final effect:

Parameter Settings and UI Elements

Some background information: the UI elements you see with a parameter are dependent on the Data type of parameter you create (Integer, Text, Date etc.) and the Allowable values settings you specify (All, List or Range):

The image below shows five Integer parameters, each created with different settings. To the right of each parameter is its respective context menu showing the different menu items available for each configuration:

If you’re using an integer Parameter with the Range option, only after specifying both a Min and Max value will the Slider option become available. Then, only after selecting the Step value will the left and right Buttons option become available.

If you’re using the List option for Allowable values then the Slider and Buttons will always be available.

Showing Only Buttons?

Unfortunately this option is not possible. The buttons are only available when the Slider option is selected and there are five allowable configurations:

With the Show buttons option selected, if you deselect Show readout or Show slider then the other one will be auto-selected.

I only wanted the arrow buttons visible, so to get around this, I formatted the parameter to have black text so it blended into the background. 

Here it is with the default formatting:

And after formatting the Font and Shading to be black:

But when I tested this on Server, the Readout background became grey:

Therefore, I changed the position of the buttons to put them on the left and hung the Readout portion off the visible area of the dashboard so it wasn’t visible on the dashboard on server:

Creating the Sheet Swap

For the sheet swapping to work a filter must be added to each sheet based on the parameter.

First, create a calculation called Metric Filter that returns the value of the parameter and drag this to the Dimensions area of the Data Pane:

My parameter is an Integer list with 3 values: 1,2,3. Set the parameter to the first value of 1.

Add the Metric Filter calculation to the view on the Filter shelf and set the value to 1, which will be the only value available in the filter dialog:

Go to the next sheet and change the parameter value to 2

Add the Metric Filter calculation to the filter shelf and set the value to 2. Again, this will be the only available value:

Repeat the above steps for the final sheet (or more if you have them).

If you now switch back to your other sheets you’ll see that they are only showing data/charts if the parameter is set to the value specified in the filter.

Add Sheets to the Dashboard

For this technique to work:

  • All sheets must be in a container
  • All sheet titles must be hidden

Below, you can see all three sheets are in a horizontal container with only one visible, based on the current parameter value. The other sheets are in the container but only a 1 pixel wide outline can be seen when they are selected:

Show the parameter on the dashboard and set it to be a Slider using the parameter context menu with the options for Show buttons and Show readout selected.

As you click on the left and right arrow, the parameter value changes, which changes the value of the Metric Filter calculation which determines which sheet is visible or hidden. Only one sheet will be visible at a time.

Workbook Example

Click here to open an example workbook on Tableau Public that you can download or explore online.

I hope this was helpful and thanks for reading.

Marc Reid
Twitter | Linked In | Tableau Public

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


Up ↑

%d bloggers like this: