2022: Week 17 - Solution
Solution by Tom Prowse and you can download the workflow here.
The challenge this week is to show how data prep can really help you out in situations where you are working across different levels of aggregation and want to save yourself from making complicated calculations within Tableau Desktop.
Step 1 - Location Spelling Errors & Timestamps
At this stage our data should now look like this:
Step 2 - Content Type
Then the second step on this branch is to calculate each of the users first streaming month. Therefore, we can use a fixed LOD to find the minimum timestamp for each user:
Min Active Month
And then convert this field to a Month level using the following calculation:
Min Active Month
DATE(DATETRUNC('month',[Min Active Month]))
Secondary Branch
We can repeat the same process but on a separate branch and this time we want to Exclude Cardiff, Edinburgh, and London from the Location list. Then update the null values in the Content Type to Secondary. We should now have a mix of Secondary and Preserved content types.
Again we can repeat the minimum month calculations, but this time we want to find the minimum month for each user, content type, and location combination.
Then we can convert this date to a month level:
Min Active Month
DATE(DATETRUNC('month',[Min Active Month]))
At this stage our workflow should be split into two separate branches that look a little like this:
Now we need to combine these branches together by using a Union step to combine them into a single table. The data should now look like this:
Step 3 - Join Avg Pricing
Finally we want to combine the Avg Pricing table into our workflow. Before joining the tables we need to ensure that the Month field is formatted in the same way, so we need to update the Month data type to a Date in both inputs/branches.
We can then join the tables together, ensuring that we make sure that all values from the Streaming branch are included because we want to include all of the content types (the Preserved content will drop out with an inner join), and we can join on Month = Min Active Month and Content Type = Content Type:
The final steps are to remove any fields that are no longer required, and then replace the null values in the Avg Price field with '14.98'.
After these changes our table should look like this and we are ready to output our data: