In this article, I will show you how to compute week to date (WTD) and previous week to date (PWTD) values using Tableau date diff() function.
Using the Sample-Superstore data, you can compute WTD sales using the formula below.
Computing WTD
Adding this calculation to the label shelf returns 4,531 which is the total sales between September 26th, 2021 (start of this week) and Today (date of publishing the article) September 30th, 2021.
Computing PWTD
Adding this calculation to the label shelf returns 19,613, which is the total sales between September 19th,2021 (Start of last week) and date equivalent to today in the previous week i.e., September 23rd, 2021.
With these two calculations you can compute, sales difference between WTD sales and PWTD sales as shown below.
Or compute percent sales difference between WTD sales and PWTD sales as shown below.
I hope this article was helpful to you. To receive more of the Tableau tips kindly join our mailing list by subscribing below.
If you like the work we do and would like to work with us, drop us an email on our Contacts page and we’ll reach out!
Thank you for reading!