Improving Parameter Design: Part 6 of 5 (Encore #1)
Creating Multiple Select Parameters in Tableau
Welcome to the 6th of five posts (yes, this is the first encore) on improving parameter design in Tableau. So far we have discussed:
- how parameter formatting hasn’t improved over time and gave one possible design solution and wrote a how-to on the topic.
- the need for toggle buttons for boolean values and give an example.
- the need for linked parameters–how parameters interact with each other and respond to each others values and build it with multiple sheets.
- how to create a slider that you can format. This used external data but was linked via a parameter action.
- how to create a vertical slider.
In this post we discuss how to build a multiple select parameter. There have been similar blogs that have discussed how to do this including Marc Reid’s blog on creating a selection panel and Tableau Zen Master Hall of Famer Jonathan Drummey’s detailed post on using parameters as a data source. Both describe use cases in great detail. This post will differ as it offers a simplistic approach to the development of multiple select parameters and more-or-less uses the same base framework.
Additionally, we secretly believe that multiple-select parameters will be offered in a future release of Tableau on the not-too-distant future. We don’t have any inside information on this, rather deducting it from recent developments on Tableau’s Community forum indicating that the IN operator/function has been planned for development.
If we re-visit the problem for the moment is that we continue to be stuck with just these four options for how parameters look-and-feel. The community continues to ask for more from Tableau and it’s developer team. But with the release of parameter actions we can actually mimic parameters using a well-formatted sheet and parameter actions.
For this post we’ll show you how to create parameter actions that drive the selection of more than one parameter. There are lots of use-cases for this: 1) you have to use a parameter across multiple data sources, 2) you want to create a chart legend that also acts as a selector, 3) you want to be able to select multiple levels for scenario planning, 4) you just want multiple selection parameters.
In the example below we use a formatted sheet, and parameter actions to select more than one segment to show in the table below:
Step #1: Build a visualization where you will eventually apply the parameters.
For my example we’ve built a table of sales, profit, and profit ratio for states in the south. We’ll eventually add my multi-select parameter as a filter. We could have also incorporated the multi-select parameters inside a calculation but we are going to keep this one simple.
Step #2: Create string parameter with no values in the parameter for now.
Don’t worry. This is just going to mean that we have no values from the parameter selected at this time. We named the parameter [MultiParam]. Note: the screenshot below was created with Editor on Tableau Server.
Step #3: Create a sheet that will be used for the multi-select parameter.
For this example we’ll drive parameter actions with the [Segment] dimension for that I’m going to build out my visual. That will look like this:
To build this, We’ve added [Segment] to rows. We’ve created
MIN(0.0) calculation and added this to columns twice and synchronized the axes. Set one mark type to circle with 40% opacity and the other marks card to shape and use an open circle. This will give the open bubble effect above. Finally edit the axes to go from -1 to 10. Then add [Segment] to text on one of the marks cards. Then format. You shouldn’t have anything on color yet (even though the image shows it). That’s coming next.
Step #4: Create a calculation that identifies if a member is in the parameter or not.
Here we’ll create a calculation called [On/Off]. This calculation is a boolean (TRUE/FALSE) and uses the contain function to look for the segment values inside the [MultiParam] parameter (which is currently empty).
// On/Off CONTAINS([MultiParam], [Segment])
You can add this to color on your parameter sheet and set a color for non-selected/FALSE values.
Step #5: Create the calculation that will drive selection/deselection.
// pram action IF CONTAINS([MultiParam], [Segment]) THEN REPLACE([MultiParam], [Segment], "") ELSE [MultiParam] + ", " +[Segment] END
If a member of [Segment] is in the [MultiParam] parameter then it’ll remove the value. If its not in the parameter then it’ll add the value to the [MultiParam] string.
Add this calculation to detail of the parameter sheet.
Step #6: Create dashboard.
For the dashboard we’ll be adding the parameter sheet and the table to a single dashboard. We’ll also format.
// Parameter as percent [switch]/100
Step #7: Add a parameter action on the dashboard.
Setup the parameter action so that when you select a value on the parameter sheet the [MultiParam] sheet will update with the [param action] calculation.
Step #9: Add a filter to automatically deselect the slider after a click.
This is one of my favorite techniques for automatically deselecting text. You can read about it in detail here.
First create two calculated fields. One called [TRUE] with the value of
TRUE and the other calculation of [FALSE] with a value of
FALSE. Add these calculations to detail the slider visualization.
Add a filter action. Select the color sheet on the dashboard. Run the action on select. Set the target dashboard to the color sheet–not the dashboard. Show all values when clearing the selection. Target filters will be [TRUE] for source and [FALSE] for target.
// pram action IF CONTAINS([MultiParam], [Segment] + ",") THEN REPLACE([MultiParam], [Segment] + ",", "") ELSE [MultiParam] +[Segment] + "," ENDBeyond that, we hope this enhances your visualizations and gets your users exactly what they need! We’ll also have at least one more encore so check back in!