2024: Week 13 - Solution



Solution by Tom Prowse and you can download the workflow here



Step 1 - Input Data

The first step is to ensure that we have all of the data that we require from the multiple different sheets within the input. As they all have a similar structure we can use the union multiple tables functionality to input these as a single input. We want to include all of the sheets within the input:



Within our input the File Paths field can become our Year field and the table should look like this: 



Step 2 - Easter Week Number

Now we have all of the data in our workflow we can start to calculate the week number that Easter occurs in each year. To do this we want to duplicate the Sales Date field, and then convert this to a Week Number using the Convert Dates functionality.



This will then become our Week Number field. 

Then to find the Easter Week Number we can rank these weeks to get the 12 previous weeks that the Easter products have been released. We need to group by Year and use a dense rank based on the Week Number in an ascending order.


This allows us to give the 12 weeks a common week number instead of the actual week number within the year. 



Step 3 - Weekday

Now we have the Easter week number we can then see what day of the week the sales were made on.

First we need to identify the day of the week so we can again duplicate the Sales Date field then convert this to the Day of the Week: 



Then using this field we can create an abbreviated weekday name as in the requirements. For the majority of the days we can just take the first letter, but for Tuesday/Thursday and Saturday/Sunday we need to take the first 2 letters. 

Weekday 
IF STARTSWITH([Sales Date-1],'T') OR STARTSWITH([Sales Date-1],'S')
THEN LEFT([Sales Date-1],2)
ELSE LEFT([Sales Date-1],1)
END

We can then give each of these days an associated number by using the Year & Easter Week Number and ranking them based on the Sales Date: 

 


Finally, the last part of the challenge is to calculate the Sales by multiplying the Quantity by the Price: 

Sales 
[Quantity Sold]*[Price]

We are then ready to output the data as per the requirements:


You can download the output from here. If you want to check your results. 

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! 

Popular posts from this blog

2024: Week 1 - Prep Air's Flow Card

2023: Week 1 The Data Source Bank

How to...Handle Free Text