Last Modified Date: 20 Jul 2023
Environment
Tableau DesktopAnswer
CLICK TO EXPAND STEPS
Option 1 - All years
The example below shows continuous month/day level data for multiple years on the same graph.
Creating a calculated field that pulls out the month/day data without the year. The attached example workbook uses the sample data set Superstore to demonstrate the following directions:
Creating a calculated field that pulls out the month/day data without the year. The attached example workbook uses the sample data set Superstore to demonstrate the following directions:
- Drag [Sales] onto the Rows shelf.
- Drag [Order Date] onto Color on the Marks card.
- Create a calculated field with a name like "Date without year" with a calculation similar to the following:
DATEADD( 'year', DATEDIFF('year',[Order Date],TODAY()), [Order Date] )
- All dates in Tableau Desktop must have a year, but for the chart we want all data on the same month/day to be grouped despite the year.
- Therefore we have given all of the date values the same year.
- Right-click and drag [Date without year] to the Columns shelf.
- In the Drop Field dialog, select the green (or continuous) DAY(Date without year) and click OK.
Note: the video has no sound. To view the video in higher quality, click the YouTube icon below to watch it on YouTube directly.
CLICK TO EXPAND STEPS
Option 2 - Two years
The below example shows how to compare two date ranges from the same data set on one graph.
- Create a calculated field for the first date range. The example below uses the year 2018:
date(IF year([Order Date])=2018 THEN [Order Date] END)
- Create a calculated field for the second date range. The example below uses the year 2019:
date(IF year([Order Date])=2019 THEN [Order Date] END)
- Place both calculated fields on the Columns shelf, selecting Continuous, Exact Date.
- Right-click the second date range and select Dual Axis.
- Drag Sales to Rows.
- Drag Order Date to Color on the Marks card for All.
Note: the video has no sound. To view the video in higher quality, click the YouTube icon below to watch it on YouTube directly.
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