KNOWLEDGE BASE

Creating a Filter for Start and End Dates Using Parameters


Published: 17 Jan 2014
Last Modified Date: 27 Nov 2023

Question

How to create parameters to filter views to specific start and end dates

Environment

Tableau Desktop

Answer

Step 1: Create Start Date and End Date Parameters

  1. In the left-hand data pane, click the drop-down arrow at the top right of Dimensions, and then select Create > Parameter
  2. In the Create Parameter dialog box, name the parameter. In the example workbook, the parameter is named Start Date.
  3. Under Data Type, select Date.
  4. Under Allowable values, select Range.
  5. Select When workbook opens and select the date field. In the example workbook, the date field is named Order Date.
  6. Click OK.
  7. Right-click the Start Date parameter in and select Duplicate
  8. Right-click the Start Date (copy) parameter and select Rename. Rename the parameter to End Date.
  9. Right-click each parameter and then select Show Parameter Control.

Step 2: Create a Date Range Calculation

  1. Right-click Order Date in the Dimensions pane and then select Create > Calculated Field
  2. Name the calculated field Date Range Filter, and type the following in the Formula window, and then click OK:
    [Order Date] >= [Start Date] 
    AND 
    [Order Date] <= [End Date]

Step 3: Add Date Range to Filters

  1. Drag Date Range Filter to the Filters shelf.
  2. In the Filter dialog, check only True, and then click OK.
  3. Optional: Right-click Date Range Filter on the Filters shelf, select Apply to Worksheets > All Using this Data Source.

Additional Information

Creating start and end date parameters provides more flexibility over the standard range of dates filter. Examples of when you might want to use start/end parameters rather than the range of dates filter include:

  • Applying the date range to only specific fields and not the whole view. This would involve creating a calculation like
    IF [Date Range Filter] THEN [Field] END
  • Sharing the filter across multiple data sources when date field is NOT an active blending link. This would involve creating a calculation like [Date Range Filter] in each data source
Did this article resolve the issue?