How to show current month values with start and end dates of the month in the header
Published: 31 Jan 2020 Last modified date: 21 Oct 2022
Question
How to show current month values with start and end dates of the month in the header
Environment
Tableau Desktop
Answer
1. Create a calculated field called Current month value with the following formula: If DATEDIFF('month',[Order Date],TODAY())=0 then [Value] end
2. Create the view like below with the Field in rows and calculated field value as a Measure value:
3. Right click the Measure name value and deselect the Show header option:
4. Open a new sheet and Create calculated fields like below for start and end dates of month:
Name of calculated field: Start of current month Formula: If DATEDIFF('month',[Order Date],TODAY())=0 then DATETRUNC('month',[Order Date]) end
Name of calculated field: Last date of current month Formula: If DATEDIFF('month',[Order Date],TODAY())=0 then DATEADD('second',-1,DATEADD('month',1,DATETRUNC('month',[Order Date]))) end
5. Drag the above created calculated fields to Rows to place them beside each other with start of current month field being the field on left. 6. Right click the field on Rows shelf and choose Custom Date representation as below:
7. Drag another instance of the Start of current month and Last date of current month to filter and choose the Non Null value. 8. Create a calculated field Empty with the formula : " " 9. Drag the Empty calculated field to text on Marks Card. 10. Create a field like "to" in between the Start of current month and Last date of current month fields on Rows shelf as shown in the screenshot below: 11. Open a new dashboard and drag the sheet with view first. 12. Change to Floating instead of the Tiled Layout and drag the start and end sheet to the position of the header by adjusting the width of the view accordingly.
Below is the final output generated:
Thank you for providing your feedback on the effectiveness of the article.