KNOWLEDGE BASE

Create a Multiple Value Selection Parameter


Published: 26 Jan 2017
Last Modified Date: 30 Oct 2018

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

Option 1: 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 Filers shelf
  7. In the Filter dialog, check True and click OK

Option 2: Using Regular Expressions
  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 (regex)"
    2. In the formula field, create a calculation similar to the following:
      REGEXP_MATCH([State],REPLACE([Multi-Search], "," , "|" ))
  6. Drag [String Match (regex)] to the Filers shelf
  7. In the Filter dialog, check True and click OK

Additional Information

Limitations:

  • The values to match must be entered manually (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

Option 1 limitations:

  • String functions can slow down performance
Option 2 limitations:
  • Will only work with data sources that support REGEXP_MATCH(), or with an extract.
  • Because the above method uses REGEXP_MATCH(), the parameter string is otherwise handled as a Regular Expression. Metacharacters (such as ^,+,*, and $) cannot be matched without a backslash (\^,\+,\*,\$), and metacharacter use without a preceding backslash may interfere with the proper functioning of the string match.
  • Tableau Technical Support cannot provide assistance writing custom regex code
Did this article resolve the issue?