Week to Date vs. Previous Week to Date in Tableau (WTD)

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.

Tableau is a fantastic tool because of its flexibility, but it takes some time to master. Nowhere is this more evident than date calculations. Many of our most read blog posts deal with topics like comparing Month to Date vs. Previous Month to Date.

I was looking back over old posts and realized that I never wrote about comparing weeks. I am writing this post on August 26th, 2020 (Wednesday). Let’s imagine I want to compare this week to date (Sun-Weds) to last week to date. Here’s how we can do that.

I am going to use Superstore data for this demonstration and want you to first see that there are sales for each day of the year.

 
145-1.png
 

Now let’s say the question I am trying to answer is, “How is each category performing Week to Date vs. Previous Week to Date?”

I’m going to stay in the above worksheet while I build and test the calculations.

The first calculation will be calculating week to date sales.

145-2.png

If we add that as an additional column to the text table, we should only see sales values returned for days from this week.

 
145-3.png
 

The next calculation will be for sales from the previous week to date.

145-4.png

DATEDIFF ensures the data is from last week and the DATEPART function ensures the weekday isn’t later in the week than today’s date.

Once again, we’ll add the calculation as a new column in the text table to perform a test.

 
145-5.png
 

Now that we have ensured both calculations work, we are ready to calculate the difference between the two values.

We can calculate that difference as either a dollar value or a percentage.

Here is the calculation for finding the dollar value difference.

145-6.png

Here is the calculation for finding the percent difference.

145-7.png

After some number formatting, here are all the calculations combined in a single worksheet to help us answer our original question.

145-8.png

Want help with your own calculations or visuals? Book an upcoming office hour or shoot me an email!

How to Create a Dynamic Measure with Multiple Number Formats in Tableau

Tableau Color Palettes with Many Colors (40+)

0