2024: Week 14 - Solution


Solution by Tom Prowse and you can download the workflow here.



Step 1 - Recalled Items

The first step is to identify which items have been recalled, these can be found in the Recalled Items table but we need to identify these at a store level. 

To do this we can use an inner join on product ID between the two tables: 


This acts like a filter and only returns the items that have been recalled. After removing the duplicate fields the table should look like this: 


Step 2 - Total Losses

Next we can calculate the total losses as a result of the recalled items. 

For this we need to calculate the total price of the items recalled. We calculate this by multiplying the Unit Price by the Quantity. 

Total Price 
[Unit Price] * [Quantity]

We can then use this to calculate the total losses split by Category and also by Store. For this we'll need two separate aggregation tools on different branches. 

Per Category



Per Store 



We can then make sure the Total Price field is rounded to 2 decimal places by using the calculation: 

Total Price Rounded 
ROUND([Total Price],2)

This same calculation can be repeated on both branches. 

Step 3 - Output

Next we are ready to output our first table - Losses per Category. For this we just need to make sure the fields match the output and the table should look like this: 



The 2nd output, we need to add the Issue Level field by categorising the values based on if they have made more than £5,000 in losses or not. We calculate this using an IF statement: 

Issue Level
IF [Total Price Rounded] >5000 
THEN 'High Priority'
ELSE 'Low Priority'
END

We can then output the 2nd table showing the Store information: 



You can download the outputs from here.

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

2023: Week 1 The Data Source Bank

2023: Week 2 - International Bank Account Numbers

How to...Handle Free Text