1. Overview
You can create a date parameter in Tableau from the Data pane. In Tableau, a date parameter allows users to interact with data by selecting a specific date. Here’s a concise guide on how to create and use a date parameter:
2. Create a date parameter in Tableau
Open Tableau and Access Parameters: Open your Tableau workbook and go to the Data pane.
Create the Parameter: Right-click on Parameters and choose Create Parameter….
Configure the Date Parameter:
- Name: Enter a descriptive name (e.g., “Selected Date”).
- Data Type: Select Date.
- Current Value: Set a default date.
- Allowable Values:
- All: Users can select any date.
- List: Specify a list of dates.
- Range: Define a start and end date for selection.
After setting up the parameter, click OK. It will now appear in the Parameters section of the Data pane.
2.2. Format of the date parameter
In Tableau, you can set the display format for a date parameter to ensure, it is in a way that suits your analysis and audience. Here’s how to manage the display format for a date parameter:
After creating the parameter, right-click on the parameter and select Edit. In the Edit Parameter dialog, you can set a custom display format using the following steps:
- Format: Use the format options to specify how the date should appear (e.g.,
MM/DD/YYYY
,DD-MM-YYYY
, etc.). - Custom Format: To set a custom date format, go to the Format pane, then select the Date field and specify the format you prefer.
Example Date Formats
- MM/DD/YYYY: 12/31/2024
- DD-MMM-YYYY: 31-Dec-2024
- YYYY-MM-DD: 2024-12-31
- MMMM DD, YYYY: December 31, 2024
If you want to pass a date parameter, you can use the following syntax:
http://<TableauServerURL>/views/<WorkbookName>/<ViewName>?:parameter_name=yyyy-mm-dd
You must format the dates in URLs correctly, usually in YYYY-MM-DD
format. Refer to this article on how to send the date parameter in a Tableau REST API.
2.2. Tableau use the date parameter
Show Parameter Control: Right-click on the parameter in the Data pane and select Show Parameter Control. This will add a control to your dashboard, allowing users to select a date.
Create a Calculated Field: Use the date parameter in a calculated field to manipulate or filter your data based on the selected date. Here’s how:
- Go to the Data pane, right-click on the dataset, and select Create Calculated Field.
- Name the calculated field and enter a formula like:
IF [Order Date] = [FROM_DATE] THEN [Order ID] END
Apply the Calculated Field as a Filter:
- Drag the calculated field you created to the Filters shelf.
- In the Filter dialog, choose to show only non-null values to filter the data based on the selected date.
In the image below, the FROM_DATE parameter has a default value of 09-06-2014. In the calculated field, we compare the Order Date with this parameter value and return the Order ID. As a result, you can only see the orders from 09-06-2014 in the visualization.
Integrate into Visualizations: Use the calculated field in your visualizations.
3. Summary
If you create a date parameter in Tableau, it enhances user interactivity and provides a dynamic way to filter and analyze data based on user-defined date criteria. For more Tableau tutorials, refer to these articles.
You can find our code samples in our GitHub repository.