KNOWLEDGE BASE

Dynamically Filtering Views with String Parameters


Published: 27 Sep 2013
Last Modified Date: 26 Nov 2014

Question

How to use a parameter to search a field for a string value.

Environment

Tableau Desktop

Answer

Create the Parameter

  1. Open Tableau Desktop and connect to Superstore sample data.
  2. Right-click in the Data window and then select Create Parameter.
  3. In the Create Parameter dialog box, do the following, and then click OK:
    • Name the parameter. In the example workbook, the parameter is named Enter Search String for Item.
    • For Data Type, select String.
    • For Current value, type a.
    • For Allowable values, select All.
  4. Right-click the parameter and then select Show Parameter Control.

Create the Calculated Field

  1. Select Analysis > Create Calculated Field.
  2. In the Calculated Field dialog box that opens, do the following and then click OK:
    • Name the calculated field. In the example workbook, the calculated field is named Item Contains Parameter Value.
    • In the formula field, create a calculated field similar to the following:
      CONTAINS([State],[Enter Search String for Item])

Create the View

  1. Drag Category to Columns.
  2. Drag Sales to Rows.
  3. Drag Category to Color.
  4. Drag State to Detail.
  5. Drag Item Contains Parameter Value to Filters.
  6. Select True, and then click OK.
Did this article resolve the issue?