Month to Date vs. Last Year Month to Date in Tableau

By: Eric Parker

Pro Headshot.jpg

Eric Parker lives in Seattle and has been teaching Tableau and Alteryx since 2014. He's helped thousands of students solve their most pressing problems. If you have a question, feel free to reach out to him directly via email.

Imagine you are asked the question, “How do this month’s sales compare to this same period from last year?” The simplest way to address this in Tableau would be to create some calculations.

Side-note: If you’re looking for something that can calculate every month (as opposed to a single month) to the previous year, check out this blog post.

First, we can create the Month to Date Sales calculation.

 
159-1.png
 

 Next, we can create the Last Year Month to Date Sales calculation.

 
159-2.png
 

The day function returns the day of the month. I’m writing this on September 24th, so this would return data from 12 months ago (September, 2019) on the 24th day of the month or earlier.

Now is a great time to check out calculations to make sure they are working properly. As you can see, the values are returning values for the proper years, month and days.

 
159-3.png
 

Now we can write the calculations which find the difference between this month to date and the same period last year.

Here’s what the dollar difference calculation looks like.

 
159-4.png
 

And here is what the percent difference calculation looks like.

159-5.png

Here is what those calculations can look like put into practice after adjusting the number formatting, creating custom labels and modifying the tooltips.

159-6.png

Want help with your own calculations? Sign up for a Tableau Office Hour to get Eric’s help!

Five Keys to Successful Tableau Whiteboarding Workshops

Create Lines with Different Shapes in Tableau (v 2023.1 and Earlier)

0