KNOWLEDGE BASE

Filtering Data With a Parameter


Published: 08 Sep 2014
Last Modified Date: 19 Nov 2017

Question

How to filter data utilizing a parameter.

Environment

Tableau Desktop

Answer

The following instructions can be reviewed in the workbook attached below.

Step 1: Creating the parameter

  1. Right-click in the data pane and select Create Parameter....
  2. In the dialog box, name the parameter. In this example, the parameter is named Toggle. 
  3. Under Data type select String.
  4. Under Allowable values select List.
  5. Next, select Add from Field > Region.
  6. Add an additional value of All with the display text of All.
  7. Click OK.

Step 2: Creating the primary calculated field

  1. Right-click in the data pane and select Create Calculated Field....
  2. In the dialog box, name the calculated field. In this example, the calculated field is named State Calc.
  3. Enter a formula similar to the following:
    IF [Toggle] = [Region]
    THEN [State]
    ELSEIF [Toggle] = "All"
    THEN [State]
    END
  4. Click OK.

Step 3: Creating the filtering calculated field

  1. Right-click in the data pane and select Create Calculated Field....
  2. In the dialog box, name of the calculated field. In this example, the calculated field is named Contains.
  3. Enter a formula similar to the following: CONTAINS([Region],[Toggle]) OR [Toggle]='All'.
  4. Click OK.

Step 4: Creating the view

  1. Drag Sales to the columns shelf and drag State Calc to the rows shelf. 
  2. Right-click on Toggle and select Show Parameter Control.
  3. Drag Contains to the filters shelf and select True.
  4. Click OK.
Did this article resolve the issue?