KNOWLEDGE BASE

Creating a Date Range Filter That Automatically Updates


Published: 10 Feb 2014
Last Modified Date: 20 Apr 2017

Question

How to create a date range filter that updates based on the range of dates in the underlying data.

Environment

Tableau Desktop

Answer

Step 1: Create Start and End Date Parameters

  1. Right-click in the Data window and then select Create Parameter.
  2. In the Create Parameter dialog box, do the following, and then click OK:
    • Name the parameter. In the example workbook, the parameter is named Start date.
    • For Data Type, select Date.
    • For Allowable values, select All.
  3. Right-click the parameter and then select Show Parameter Control.
  4. Repeat steps 1-3 to create an End date parameter.

Step 2: Create a Parameter to Control a Filter

  1. Right-click in the Data window and then select Create Parameter.
  2. In the Create Parameter dialog box, do the following, and then click OK:
    • Name the parameter. In the example workbook, the parameter is named Filter ON/OFF.
    • For Data Type, select String.
    • For Allowable values, select List.
    • In List of values, add ON and OFF.
  3. Right-click the parameter and then select Show Parameter Control.

Step 3: Create a Calculated Field to Use as a Filter

  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 Filtered date.
    • In the formula field, create a calculated field similar to the following:
      IF [Filter ON/OFF]="OFF" THEN [date] ELSEIF [date]<[End date] AND [date]>[Start date] THEN [date] END
    • Note: Replace [date] with the date field you would like to filter.
  3. Drag the newly created calculated field from the Dimensions pane to the Filter shelf.
  4. In the Filter dialog box that opens, select Months, and then click Next.
  5. Select Exclude and Null, and then click OK.

Step 4: Create the View

  1. Drag Filtered date to Columns.
  2. Drag Filtered date to Columns again, right-click Filtered date on Columns, and then select Month.
  3. Drag amount to Rows.
  4. Drag type to Color.
  5. For Marks, select Bar.
Did this article resolve the issue?