Home › Blog › Tableau: Compare Same Period Last Year (YoY)

Tableau: Compare Same Period Last Year

Step 1:

Create a crosstab by dragging order date to rows, and sales to the text shelf. In this data, we only have December 2019 and 2020. In 2020, the data ends at the 20th of the month.

Tableau: Compare Same Period Last Year - step 1 screenshot

Step 2:

Create a calculation for this year sales by using this calculated field.

if year([Order Date]) = year({Max([Order Date])}) then [Sales] END

Tableau: Compare Same Period Last Year - step 2 screenshot

Step 3:

Copy the calculated field and modify it for last year.

if year([Order Date]) = year({Max([Order Date])})-1 then [Sales] END

Tableau: Compare Same Period Last Year - step 3 screenshot

Step 4:

In order to only compare month to date for 2019, we’ll need to add a filter. Use this calculation to test if the day is less than the max day in 2020.

day([Order Date]) <= day({max([Order Date])})

Tableau: Compare Same Period Last Year - step 4 screenshot

Step 5:

Drag that calculation to the filter shelf, and keep only True values

Tableau: Compare Same Period Last Year - step 5 screenshot

Step 6:

Now, you can remove the order date pill, and create a bar chart by dragging measure values to the row shelf.

Tableau: Compare Same Period Last Year - step 6 screenshot

Work with Robert

Tell me what's eating your team's time. I'll show you what's worth automating and what it's worth to you. Free first call, and a clear quote before any work starts.

Goes only to Robert. No newsletter, no spam.