KNOWLEDGE BASE

Create a Multiple Value Selection Parameter


Published: 26 Jan 2017
Last Modified Date: 01 Mar 2024

Question

How to filter a view by a list of values typed in by the user. This list can be used to select multiple values in a parameter. For example, filtering the view to the states "Illinois, Maine, New York".
 

Environment

Tableau Desktop

Answer

These options are demonstrated using the sample data set Superstore in the workbook available to download from the right-hand pane.

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.
  1. Right-click [State] in the left-hand data pane and Create > Set…
  2. In the Create Set dialog, give the set a name and click OK. In this example, the set is called "State Set A"
  3. Right-click [State Set A] in the data pane and check Show Set
  4. Repeat steps 1-3 to for "State Set B"
  5. Select Analysis > Create Calculated Field
  6. the Calculated Field dialog box that opens, do the following, and then click OK:
    1. Name the calculated field. In this example, the calculated field is named "Selected states filter"
    2. In the formula field, create a calculation similar to the following:
      [State Set A] OR [State Set B]
  7. 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
  8. Double-click [State] in the data pane to create the map
  9. Drag [Selected States Color] to Color on the Marks card
  10. Drag [Selected states filter] to the Filters shelf
  11. In the Filter dialog, check True and click OK
Option 2: Using string functions
  1. Click the down arrow next to Dimensions in the data pane and select Create Parameter…
  2. In the Create Parameter dialog, do the following and click OK:
    1. Name the parameter. In this example I will call it "Multi-Search"
    2. For Data Type, choose String
  3. Right-click [Multi-Search] in the data pane and select Show Parameter Control
  4. Select Analysis > Create Calculated Field
  5. In the Calculated Field dialog box that opens, do the following, and then click OK:
    1. Name the calculated field. In this example, the calculated field is named "String Match (contains)"
    2. In the formula field, create a calculation similar to the following:
      [Multi-Search] = ""
      OR
      CONTAINS([Multi-Search],[State])
  6. Drag [String Match (contains)] to the Filters shelf
  7. 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
Additional Functions
Creating a Parameter List with an Option to Filter by All Values
Create Sets
 
Did this article resolve the issue?