KNOWLEDGE BASE

Creating a Date Field that Defaults to Today's Date


Published: 21 Jul 2014
Last Modified Date: 12 Jan 2017

Question

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

Environment

Tableau Desktop

Answer

Option 1: Create a Simple Parameter

  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 Today.
    • For Data Type, select String.
    • For Current value, enter Today.
    • For Allowable values, select All.
  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 Date Conversion.
    • In the formula field, create a calculated field like the following: 
      IF [Today]="Today" THEN TODAY()
      ELSE DATE([Today])
      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 Date Calculation.
    • In the formula field, create a calculated field like the following: 
  • IF [Date Conversion] = [Order Date] THEN [Order Date]
    END
  1. Add the new Date Calculation field to the view and use it as you would use a normal DATE field.

Option 2: Create a List Parameter

  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 Date List.
    • 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 Date List Conversion.
    • In the formula field, create a calculated field like the following: 
      IF [Date List]="Today" THEN TODAY()
      ELSE DATE([Date List])
      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 Date List Calculation.
    • In the formula field, create a calculated field like the following: 
      IF [Date List Conversion]=[Order Date] THEN [Order Date]
      ELSE DATE([Today])
      END
  9. Add the new Date List Calculation field to the view and use it as you would use a normal DATE field.
Did this article resolve the issue?