KNOWLEDGE BASE

How to Display the Corresponding Date Range When a Year Is Specified by a Parameter


Published: 08 Jun 2023
Last Modified Date: 13 Jun 2023

Question

How to display the corresponding date range when a year is specified in a parameter.

Environment

  • Tableau Desktop

Answer

Below is an example of displaying a data range for a year specified by a parameter.
User-added image

1. Create a calculated field and name it Year List.
DATE(DATETRUNC('year',[Order Date]))
2. Create a parameter as follows;
Note: In the attached sample workbook, Allowable List values are added by selecting Year List from Add values from drop-down, and the Display format is changed to Custom (yyyy).
 User-added image
3. Create a calculated field and name it Start Date.
DATE(DATETRUNC('year',[Year]))
4. Create a calculated field and name it Start Date (weekday).
LEFT(DATENAME('weekday',DATETRUNC('year',[Year])),3)
5. Create a calculated field and name it End Date.
DATE(DATEADD('day',-1,DATEADD('year',1,DATETRUNC('year',[Year]))))
6. Create a calculated field and name it End Date (weekday).
LEFT(DATENAME('weekday',DATEADD('day',-1,DATEADD('year',1,DATETRUNC('year',[Year])))),3)
7. Add Start Date (as Discrete), Start Date (weekday)End Date (as Discrete) and End Date (weekday) to Text on the Marks card.
8. Click Text on the Marks card and click [...].
 User-added image
9. Edit the label as you need like the following.
 User-added image
10. Edit the label alignment as you need like the following.
 User-added image
Did this article resolve the issue?