2022: Week 19 - Solution
Solution by Tom Prowse and you can download the workflow here.
This week we return to our favourite retailer, Chin & Beard Suds Co (C&BSCo) and are looking to identify some mistakes that are coming through within the sales and actual products sold. Let's look at how we solved the problem.
Step 1 - Combine Size & Sales
First we want to input both the Sales & Size Table sheets from our input. From here we can join these tables by using an inner join on Size = Size ID:
Then from here we can clean some of the fields by removing Size, Size ID, and renaming Size-1 to Sales Size.
Our table should look like this:
Step 2 - Product Set Correct?
Next we want to include the Product Set table and clean this so that it's in a format that we can join with our previous branch.
First, we want to ensure that the Product Code field is the same as in the other table. Therefore, we need to remove any of the S codes by using the following calculation:
Product Code
REPLACE([Product Code],'S','')
Then we want to rename Size to Product Size so that's it's easy to identify when joining later. Our Product Set table should look like this:
From here we can then start to identify the codes that match and the ones that don't. To do this we can use a couple of joins and change the conditions based on where the Size matches or not.
First is the Correct Size, here we join where Sales Size = Product Size and Product = Product Code.
Notice how this excludes some values, and these will be the values where the sizes don't match on both tables.
Before identifying the wrong sizes, we can remove the Product Code and Sales Size, then we have our first output:
To identify the wrongly matched sizes, we can again use a join, but this time the conditions will be where Product Code = Product and Product Size != Sales Size (does not equal).
Our workflow should now look like this:
Finally, the last stage is to aggregate the wrongly sized items so we can see the total by Code, Size, and Scent. The aggregate tool has the setup where we group by Product Code, Product Size, and Scent then we can aggregate by summing the total number of rows (renamed to Sales with Wrong Size) for each.
Our second output should look like this:
You can download the full output 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!