2021: Week 26 Rolling Weekly Revenue
Challenge by: Carl Allchin
For any analyst, you are likely to get asked to use some complex calculations. For me, rolling or moving calculations are one that I've always preferred to do in the data preparation step rather than when trying to visualise the data if possible. It's saved me from some mistakes!
This week's challenge is looking at creating moving calculations. By this let's use the example below, where on 5th January (yes British date format), if we wanted to understand a rolling week's values, you can include 3 days before the 5th (ie the 2nd, 3rd and 4th) as well as 3 days after the 5th (ie the 6th, 7th and 8th).
Challenge
Create a rolling weekly total and average for each Prep Air destination and an overall number for all destinations. The rolling week is as detailed above, 3 days before and 3 days after a date as well as that day itself.
Input
Requirements
- Input data
- Create a data set that gives 7 rows per date (unless those dates aren't included in the data set).
- ie 1st Jan only has 4 rows of data (1st, 2nd, 3rd & 4th)
- Remove any additional fields you don't need
- Create the Rolling Week Total and Rolling Week Average per destination
- Records that have less than 7 days data should remain included in the output
- Create the Rolling Week Total and Rolling Week Average for the whole data set
- Pull the data together for the previous two requirements
- Output the data
Output
One table:
Four data fields:
- Destination
- Date
- Rolling Week Avg
- Rolling Week Total
360 rows (361 including headers)
Here's our full output for comparison. Remember we don't care about the order of the columns or rows as Tableau Desktop will import them in whatever order they come in!
After you finish the challenge make sure to fill in the participation tracker, then share your solution on Twitter using #PreppinData and tagging @Datajedininja, @JennyMartinDS14 & @TomProwse1
You can also post your solution on the Tableau Forum where we have a Preppin' Data community page. Post your solutions and ask questions if you need any help!