Questions from Training: Comparing Metrics for Same Weekday in Previous Year

Data

Questions from Training: Comparing Metrics for Same Weekday in Previous Year

Our Certified Tableau Trainers are asked a myriad of questions each day. In this series, they share some answers.

This is a question that came up in a class I taught to a commercial airline who were looking at their web analytics data, I also taught it in a colleague’s class dealing with car parking at airports:

“How can I compare a metric against the same weekday in a previous year?”

Do you want to investigate a metric at the day level, but the metric is vastly different on weekends? If yes, then doing a simple year-on-year comparison of the same date will not compare like with like. For example, comparing the 20th January 2018 (Saturday) to the 20th January 2017 (Friday) wouldn’t lead to useful insight in your report.

Date Table to the Rescue

One possible solution involves that repeatedly useful item – a date table. This will be a separate table in your database, or even just a well-maintained Excel sheet, containing every calendar date with extra information (such as whether it’s a weekend day or a national holiday). Into my date table, I’ve added a column called [SameWeekdayPrevYear] which was calculated in SQL (as that’s where my date table is stored) using:

DATEADD(DD, -364, d.Date)

To calculate the difference between sales for a particular order date and the equivalent order date on the same weekday of the previous year, I joined my date table to my orders table on [Order Date] = [Date]. I then brought in another instance of my Orders table and joined that to my DateTable on [SameWeekdayPrevYear] = [Order Date (Orders1)]:

Tableau Orders Join

Tableau Orders Join

As I only want to return the sales for the same weekday from last year, I can hide all the other fields from my Orders1 table and rename the remaining fields: Sales (Orders 1) becomes [Sales Same Weekday Prev Year], and Order Date (Orders 1) is renamed [Order Date Same Weekday Prev Year].

This makes it straightforward to see the difference in sales between any date and the corresponding weekday of the previous year, using the following calculated field:

Diff to same weekday prev year calculation

If you want to implement this in your Tableau reports, you can download and use my sample workbook below to help you. The data source for both the tables and SQL query is the Sample Superstore, which is available from the Saved Data Sources in Tableau Desktop.

Want More Questions from Tableau Training

  1. Questions from Tableau Training: Quick Filter Interaction
  2. Questions from Tableau Training: Labeling with Table Calculations
  3. Questions from Tableau Training: Speeding Up Presentation Views when Using Tableau
  4. Questions from Tableau Training: Dashboard Actions
  5. Questions from Tableau Training: Business Day Calculations
  6. Questions from Tableau Training: Adding Gaps Between Bars
  7. Questions from Tableau Training: When to Pivot Data in Tableau
  8. Questions from Tableau Training: Adding Conditional Formatting
  9. Questions from Tableau Training: Setting Weekday Start
  10. Questions from Tableau Training: How Do ZIP Codes Work in Tableau?
  11. Questions from Tableau Training: The Small Grey Bar Within a Quick Filter
  12. Questions from Tableau Training: Matching Mark Color
  13. Questions from Tableau Training: Showing the Null Indicator
  14. Questions from Tableau Training: Can I Manually Set the Colors of a Stepped Gradient?
  15. Questions from Tableau Training: How Can I Get Box Plot Data into a Crosstab?
  16. Questions from Tableau Training: How Do I Clear a Worksheet? Make a Copy?
  17. Questions from Tableau Training: Opening URL Actions Inside of a Dashboard
  18. Questions from Tableau Training: Can I Move Mark Labels?
  19. Questions from Tableau Training: How Can I Use My Current Report to Create a Viz?
  20. Questions from Tableau Training: Can I Create Text Hyperlinks on a Dashboard?
  21. Questions from Tableau Training: How Can I Transform My Crosstab into a Flat List?
  22. Questions from Tableau Training: Labeling the Top N
  23. Questions from Tableau Training: How Can I Customize Charts with Parameters?
  24. Questions from Tableau Training: Combining Measures into a Single Line
  25. Questions from Tableau Training: How Can I Create Custom Color Palettes?
  26. Questions from Tableau Training: Can a Top N Parameter be Nested Within Other Fields?
  27. Questions from Tableau Training: Conditional Scope on Tableau Calculations
  28. Questions from Tableau Training: Top Ten Plus N
  29. Questions from Tableau Training: Dynamic Label Positioning
  30. Questions from Tableau Training: Using Cross Joins to Solve Active Tickets
  31. Questions from Tableau Training: Top N Highlight Table
  32. Questions from Tableau Training: How to Use Specific Dimensions in Table Calculations
  33. Questions from Tableau Training: Moving Reference Line Labels
  34. Questions from Training: Comparing Metrics for Same Weekday in Previous Year
  35. Questions from Tableau Training: Colouring Specific Columns and Rows in a Crosstab
  36. Questions from Tableau Training: Creating a Custom Legend as a Sheet
  37. Questions from Tableau Training: How Can I Draw a 45-Degree Angle?
  38. Questions from Tableau Training: Down the Aggregation Rabbit Hole
  39. Questions from Tableau Training: Percent Change from Previous Period on a Map
  40. Questions from Tableau Training: Union File Names as Years
  41. Questions from Tableau Training: Conditional Coloring on Sparklines
  42. Questions from Tableau Training: Moving Column Headers to the Top of the View
  43. Questions from Tableau Training: Isolating Rank with Parameters and Calculations

More About the Author

Steve Taylor

Services Lead
How to Build an XmR Chart in Tableau In this blog, I’ll run through the steps to build an XmR control chart, which is typically used to determine if a manufacturing or ...
New Features in Tableau 2020.1: Dynamic Parameters and Animations It’s a new year, so like clockwork, there’s a new release of Tableau Desktop currently in beta: version 2020.1. There are a couple of ...

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!