Last Modified Date: 20 Jul 2023
Environment
Tableau DesktopAnswer
CLICK TO EXPAND SOLUTION
Example 1: Default to Yesterday
Option 1
- Right-click and drag the date dimension to the filter shelf.
- Select Relative dates > Yesterday.
- From the filter shelf, right-click the date dimension and select Show Filter.
Option 2
- Create a calculated field by selecting Analysis > Create Calculated Field to create a calculated field.
- In the Calculated Field dialog box that opens, enter a name for the field.
- In the formula field, create a calculated field similar to the following:
[Date Field]=today()-1
- where [Date Field] is the date field being used in the view. Click OK.
- Drag the newly created calculated field from the Dimensions pane to the Filter shelf.
- In the Filter dialog box that opens, select True, and then click OK.
- From the filter shelf, right-click this new calculated field and select Show Filter.
CLICK TO EXPAND SOLUTION
Example 2: 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()
CLICK TO EXPAND SOLUTION
Example 3: Default Today, Select Other Date
This option defaults the view to today, but allows users to select a specific date from a parameter control.
- In Tableau Desktop, connect to the Sample - Superstore sample data source.
- Open the Data pane menu using the drop-down arrow in the upper-right corner and then select Create Parameter.
- 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.
- In the Data pane, click the drop-down arrow next to the parameter and then select Show Parameter Control.
- Select Analysis > Create Calculated Field.
- 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
- Select Analysis > Create Calculated Field.
- 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
- Add the new [Select Date Calculation] field to the view and use it as you would use a normal date field.
Thank you for providing your feedback on the effectiveness of the article.
Open new Case
Continue Searching
Knowledge Base
Community
Product Help
Training and Tutorials