2023: Week 20 - Solution



Solution by Tom Prowse and you can download the workflow here


This week's challenge comes from Trea McElhone and we are looking at food options at our school dining hall.

Step 1 - Group Meal Types

First we want to input our Meal Nutritional Info table where we can group the meal types into different types of food (Meat-based, Vegan, Vegetarian). 

To do this we can make use of Tableau Prep's grouping features by using the set group by pronunciation or manually group the fields as there aren't too many to group. 

If we are manually grouping then all we need to do is select the given fields in the profile pane and then right-click --> group values 



Step 2 - Combine Tables

We can now input the 2nd table that contains details about the Meal Prices. We can join the table with our existing workflow by using an inner join on the Meal Option field. 



After removing the irrelevant fields our table should look like this: 



Step 3 - % of Total

Final part of the challenge is to calculate the avg. price per type of meal and what % of the total each type makes up. 

First we want to calculate the total per type and the average price. To do this we can use an aggregation step to group by Type, Avg. Price, Count Meal Option


From here we can use these fields to calculate the % of total for each type. First we need to calculate the total number of meals across all types. We can do this by using a Fixed LOD calculation: 

Total Count 


We can then use this to calculate the percentage which is rounded to the nearest whole number: 

Percent of Total 
ROUND(([Meal Option]/[Total Count])*100,0)

We can then remove and rename some fields so that our table is then ready to output: 



After you finish the challenge make sure to fill in the participation tracker, then share your solution on Twitter using #PreppinData and tagging Trea McElhone@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