KNOWLEDGE BASE

Creating a Date Field that Defaults to Today's Date


Published: 21 Jul 2014
Last Modified Date: 30 May 2017

Question

How to set a date field that defaults to today's date.

Environment

Tableau Desktop

Answer

Option 1: Always Today

This option will always show today only. There are two ways to implement Option 1:

Create a calculation to be used in place of the original date field. For example:
IF [Order Date] = TODAY() THEN [Order Date] END
OR
Create a T/F boolean calculation and place the field on the filter shelf, set to True:
[Order Date] = TODAY()

To view these steps in action, see the video below: 

    Option 2: Default Today, Select Other Date

    This option defaults the view to today, but allows users to select a specific date from a parameter control.
    1. In Tableau Desktop, connect to the Sample - Superstore sample data source.
    2. Open the Data pane menu using the drop-down arrow in the upper-right corner and then select Create Parameter.
    3. In the Create Parameter dialog box, do the following, and then click OK:
      • Name the parameter. In this example, the parameter is named [Select Date].
      • For Data Type, select Date & time.
      • For Allowable values, select List.
      • Click Add from Field > Order Date.
      • For Data Type, change the data type from Date & time to String.
      • For List of values, add Today to the list. Drag Today to the top of the list.
      • For Current value, enter Today.
    4. In the Data pane, click the drop-down arrow next to the parameter and then select Show Parameter Control.
    5. Select Analysis > Create Calculated Field.
    6. In the Calculated Field dialog box that opens, do the following and then click OK:
      • Name the calculated field. In this example, the calculated field is named [Select Date Conversion].
      • In the formula field, create a calculated field like the following: 
        IF [Select Date]="Today" THEN TODAY()
        ELSE DATE([Select Date])
        END
    7. Select Analysis > Create Calculated Field.
    8. In the Calculated Field dialog box that opens, do the following and then click OK:
      • Name the calculated field. In this example, the calculated field is named [Select Date Calculation].
      • In the formula field, create a calculated field like the following: 
        IF [Select Date Conversion]=[Order Date] THEN [Order Date]
        ELSE DATE(Today())
        END
    9. Add the new [Select Date Calculation] field to the view and use it as you would use a normal date field.
    To view these steps in action, see the video below: 
    Did this article resolve the issue?