2023: Week 18 - Solution
Solution by Tom Prowse and you can download the workflow here.
This week's challenge takes us back to the fundamental steps within Tableau Prep - Input, Clean, Pivot, Aggregate, and Output. These are the most common steps used within Tableau Prep and are all vital when preparing data.
Step 1 - Location Names
After connecting to the 'Messy Nut House Data' as a text file we can drag in the single sheet as our input. Then we create a new clean step where we can tidy the spelling mistakes within the Location field.
To do this we can use some of the clever group features within Tableau Prep to group values by Spelling or Pronunciation.
From here we can manually rename the fields so that we have three cities - Liverpool, London, and Manchester.
Step 2 - Reshape the Table
Next we want to reshape the table so that each of the Categories become a field name. To do this we want to pivot the data using a Rows to Columns pivot where we group by Category and Sum the Value field.
As a result we now have three additional fields where the Category field has been replaced by the 3 separate values - Weight (kg), Price (£) per Pack, and Quant per Q.
Step 3 - Calculate Total Revenue & Avg Price
Once we have the Revenue on each row, we can then use an aggregation tool to find the total revenue and avg price per location. To do this we want to group by Location, and then Sum Revenue and Avg Price.
Then finally we can clean the Avg Price field by rounding the number to 2 decimal places using a Round function: