Creating a Multiple Value Selection Parameter
Option 1: Using Set Controls
Starting in Tableau Desktop 2020.2 Set Controls allow end users to change the values in a set. This example allows the users to select two sets of states to see on one map, but sets are flexible and can be used in many scenarios.
- Right-click [State] in the left-hand data pane and Create > Set…
- In the Create Set dialog, give the set a name and click OK. In this example, the set is called "State Set A"
- Right-click [State Set A] in the data pane and check Show Set
- Repeat steps 1-3 to for "State Set B"
- Select Analysis > Create Calculated Field
- the Calculated Field dialog box that opens, do the following, and then click OK:
- Name the calculated field. In this example, the calculated field is named "Selected states filter"
- In the formula field, create a calculation similar to the following:
[State Set A] OR [State Set B]
- Create a calculated field with a name like "Selected States Color" with a calculation similar to the following:
IF [State Set A] AND [State Set B] THEN 'Both' ELSEIF [State Set A] THEN 'A' ELSEIF [State Set B] THEN 'B' ELSE 'not selected' END
- Double-click [State] in the data pane to create the map
- Drag [Selected States Color] to Color on the Marks card
- Drag [Selected states filter] to the Filters shelf
- In the Filter dialog, check True and click OK
- Click the down arrow next to Dimensions in the data pane and select Create Parameter…
- In the Create Parameter dialog, do the following and click OK:
- Name the parameter. In this example I will call it "Multi-Search"
- For Data Type, choose String
- Right-click [Multi-Search] in the data pane and select Show Parameter Control
- Select Analysis > Create Calculated Field
- In the Calculated Field dialog box that opens, do the following, and then click OK:
- Name the calculated field. In this example, the calculated field is named "String Match (contains)"
- In the formula field, create a calculation similar to the following:
[Multi-Search] = "" OR CONTAINS([Multi-Search],[State])
- Drag [String Match (contains)] to the Filers shelf
- In the Filter dialog, check True and click OK
Additional Information
Option 1 Limitations:
- Sets cannot be shared across data sources
- Sets cannot contain additional values outside what is in the data, but values can be aliased
Option 2 limitations:
- String functions can slow down performance
- The values must be entered manually exactly as they appear in the data (checkboxes will not work)
- The other limitations of parameters still apply
- More advanced string parsing (removal of metacharacters, using a comma with a space as a separator, exact match, etc.) may require additional code
Thank you so much for putting up such a interesting blog post on Multiple Value Selection Parameter In Tableau.
ReplyDeleteTableau Soap Connection