KNOWLEDGE BASE

Showing Continuous Month or Day Level Data for Multiple Years on the Same Chart


Published: 07 Nov 2017
Last modified date: 20 Jul 2023

Question

How to show continuous month/day level data for multiple years on the same graph.

Environment

Tableau Desktop

Answer

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:
  1. Drag [Sales] onto the Rows shelf.
  2. Drag [Order Date] onto Color on the Marks card.
  3. 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.
  4. Right-click and drag [Date without year] to the Columns shelf.
  5. In the Drop Field dialog, select the green (or continuous) DAY(Date without year) and click OK.


 
  To view the above steps in action, see the video below.
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.
  1. 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)
  2. 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)
  3. Place both calculated fields on the Columns shelf, selecting Continuous, Exact Date.
  4. Right-click the second date range and select Dual Axis.
  5. Drag Sales to Rows.
  6. Drag Order Date to Colour on the Marks card for All.
To view the above steps in action, see the video below.
Note: the video has no sound. To view the video in higher quality, click the YouTube icon below to watch it on YouTube directly.
Did this article resolve the issue?