2024: Week 22 - Solution
Solution by Tom Prowse and you can download the workflow here.
Step 1 - Loyalty Points & Email
After inputting the table relating to Loyalty Points, we can then make sure that the DateTime_Out field is correctly formatted as a date. For this we can change the data type to a Date then rename the field to just Date.
We can then focus on the loyalty points. We want to extract the numeric part from the Loyalty Points field. We can do this by using the Automatic Split functionality which will nicely bring out just the numeric part of the string. Then we can tidy the field by changing the data type to a decimal, removing the original Loyalty Points field, then renaming the Split field to Loyalty Points.
Next we want to extract the First and Last name from the Email Address field. For this we can use a custom split on the '@' and extract everything before the symbol.
We can then split this field again using an automatic split which will extract the first name and last name initial. Then we can remove the original Split field and rename the Name fields accordingly. At this stage the table should look like this:
Step 2 - Join Tables
We can now join the Customer Details table with our existing workflow. For this we first need to extract the initial from the last name of each person using a string calculation:
Last Name Initial
LOWER(LEFT([Last Name],1))
We can then join the table just the First Name and Last Name Initial from both sides with an inner join:
We can then remove the Last Name Initial, First Name-1, and Last Name Initial-1, then join the Store Data to our workflow.
For this we can use an inner join on Store ID:
Step 3 - Rank Customers
The final step is to remove the Store ID, Store ID-1 and all Null values within the Postcode field.
We can then rank the customers per store based on their number of loyalty points. For this we can group by Store, then use a Dense rank on the Loyalty Points:
Rank
Then finally we want to only keep the top 5 so we can filter the table using the calculation [Rank]<=5
Our final output should look like this:
You can view the 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!