Tableau Deep Dive: Dates – Week-by-Week Comparison

Data

Tableau Deep Dive: Dates – Week-by-Week Comparison

Tableau Deep Dives are a loose collection of mini-series designed to give you an in-depth look into various features of Tableau Software.

In our final article in the Deep Dive on Dates, we’ll explore how to take a start date for different products and normalize it to a wee- by-week comparison from week one forward.

This article was inspired by one of my Desktop I: Fundamentals students from a Melbourne Public class last year. They worked for a publisher and wanted to show an apples-to-apples comparison of performance for new titles that they’ve released. To accomplish this, we’re definitely going to need to combine a lot of the date techniques we’ve learned during this deep dive. 

To illustrate our example, let’s grab the top five movies that were released in 2016 using data from Box Office Mojo.

Running Sum

I want to compare each movie side by side from a relative week one rather than the actual release date. If I just put them into a view without using my date functions, I’ll get a view like this:

Tableau view without date functions

For the view above, I put a Running Sum table calculation on the Weekly Gross measure:

Tableau calculation

My dates are represented as a continuous date for week number, which spreads my movies out all over the line graph.

Resetting the Week Number

The solution is to use a discrete date and to reset the date back to week number one. Let’s start by calculating the difference from week one to the actual week the movie was released. To accomplish this, we’ll need to dip back into our Level of Detail calculations! They really show up all over the place once you get comfortable with them.

We’ll use the following formula:

Week variance formula

Let’s pause and check our math in a text table, comparing the actual start with our calculation above. I highly recommend you take this extra step to ensure that your LODs are working properly. Let’s set up our text table with each movie title and the release date as row headers.

To show the first date, we need to set our date field to MIN(). To get that exact date to show up as a header, which is by default continuous, we can hardcode it as discrete.

Here’s our table with our LOD calculated field, Week Variance as the text label:

Add MIN(Date)

“Rogue One” was released in mid-December (Dec-16). The -50 calculation that’s showing up on that row means to get back to our relative week one, we must subtract 50 weeks from the start date. Our results are as expected, so let’s continue to the next step.

Week-by-Week Performance

Now that we have the variance using DATEDIFF, we can then apply it to our Week date field with DATEADD to reset every movie release to a discrete week one. I’m going to wrap the entire calculated field in the DATE () function to make sure the data type stays at date rather than date & time.

Here’s our updated calculation:

Release Data calc

Now we are ready to build our view using our Release Date calculated field that we created above as the week date part (i.e., discrete):

Add Release Date to view

To make our viz just that bit more helpful, let’s add the actual release date into the tooltip. We’ll re-use our Level of Detail calculation to find the minimum date:

Actual Release Date calc

Finally, we’ll grab this new calculation onto our tooltip and do a little clean-up to make it user-friendly:

Final view in Tableau

What’s Next?

That’s it for dates. We are finito for this deep dive! Please let me know if you have any thoughts or questions in the comments section below. And be sure to stay tuned to the InterWorks blog for all of the great content from our business intelligence experts for more data and more Tableau tips and tricks.

Cheers, and thanks for reading!

Want More Tableau Deep Dives

  1. Tableau Deep Dive: LOD – Introduction to Detail
  2. Tableau Deep Dive: LOD – The Include Calculation
  3. Tableau Deep Dive: LOD – The Exclude Calculation
  4. Tableau Deep Dive: LOD – The Fixed Calculation
  5. Tableau Deep Dive: LOD – LOD Calculations vs. Table Calculations
  6. Tableau Deep Dive: Parameters – Parameter Overview
  7. Tableau Deep Dive: Parameters – Parameter Properties
  8. Tableau Deep Dive: Parameters – Filtering – Top N
  9. Tableau Deep Dive: Parameters – Calculated Fields
  10. Tableau Deep Dive: Parameters – Filtering Across Data Sources
  11. Tableau Deep Dive: Parameters – Bins
  12. Tableau Deep Dive: Parameters – Reference Lines
  13. Tableau Deep Dive: Parameters – Table Calculations
  14. Tableau Deep Dive: Sets – Introduction to Sets
  15. Tableau Deep Dive: Sets – Constant Sets
  16. Tableau Deep Dive: Sets – Computed Sets
  17. Tableau Deep Dive: Sets – IN/OUT
  18. Tableau Deep Dive: Sets – Combined Sets
  19. Tableau Deep Dive: Sets – Calculated Fields
  20. Tableau Deep Dive: Sets – Hierarchies
  21. Tableau Deep Dive: Dates – Introduction to Dates
  22. Tableau Deep Dive: Dates – Preparing Dates
  23. Tableau Deep Dive: Dates – More Date Functions
  24. Tableau Deep Dive: Dates – Exact Dates
  25. Tableau Deep Dive: Dates – Custom Dates
  26. Tableau Deep Dive: Dates – Rolling Dates
  27. Tableau Deep Dive: Dates – Calendar Filters
  28. Tableau Deep Dive: Dates – Week-by-Week Comparison
  29. Tableau Deep Dive: Dashboard Design – Planning
  30. Tableau Deep Dive: Dashboard Design – Layout & Structure
  31. Tableau Deep Dive: Dashboard Design – Proof of Concept
  32. Tableau Deep Dive: Dashboard Design – Adding Interactivity
  33. Tableau Deep Dive: Dashboard Design – Visual Best Practices
  34. Tableau Deep Dive: Dashboard Design – Optimization & Governance
  35. Tableau Deep Dive: Dashboard Design – Publishing
  36. Tableau Deep Dive: Table Calculations – Custom Sorts, Part One
  37. Tableau Deep Dive: Table Calculations – Custom Sorts, Part Two
  38. Tableau Deep Dive: Table Calculations – Custom Sorts, Part Three

More About the Author

Robert Curtis

Managing Director, APAC
Building Solutions with InterWorks at Corinium’s Data Architecture Conference in Melbourne InterWorks was a proud sponsor of the Data Architecture Conference hosted by Corinium in Melbourne on 21 and 22 June 2023. Hundreds of ...
Virtual Event Recap: Deep Dive of Tableau Parameters For our June Lunch and Learn, we did a deep dive on parameters for our friends across Australia and Singapore. Tableau is the premier ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×

Love our blog? You should see our emails. Sign up for our newsletter!