By: Eric Parker
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.
Next, we can create the Last Year Month to Date Sales calculation.
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.
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.
And here is what the percent difference calculation looks like.
Here is what those calculations can look like put into practice after adjusting the number formatting, creating custom labels and modifying the tooltips.
Want help with your own calculations? Sign up for a Tableau Office Hour to get Eric’s help!