2024: Week 36 - Solution


Solution by Tom Prowse and you can download the workflow here.



Step 1 - Points per Game

After inputting the data we want to identify how many points each team has. We can do this in two calculated fields: 

Home Team 
IF [Home Score] > [Away Score] THEN 3
ELSEIF [Home Score] = [Away Score] THEN 1
ELSE 0
END

Away Team
IF [Away Score] > [Home Score] THEN 3
ELSEIF [Home Score] = [Away Score] THEN 1
ELSE 0
END

We can then split the workflow into two branches - one for Home, one for Away. 

Within the Home branch we want to remove fields relating to the Away team (Away Points & Away Team) then rename each of the Home fields to the following: 

Home Score --> Goals For
Away Score --> Goals Against
Home Points --> Points
Home Team --> Team

We can then calculate the goal difference for each match: 

Goal Difference
[Goals For]-[Goals Against]

We can then repeat this the away side using a separate branch.



Then we can bring both of these branches back together using a union step and the table should look like this: 




Step 2 - Running Totals

Next we want to start forming the league table. For this we need to calculate some running totals based on points, goals for & against, and goal difference. 

Goals For (RT)



Goals Against (RT)



Goal Difference (RT)



Points (RT)


Finally, we can remove all of the fields that don't include the running totals, Matchday, or Team and then calculate the sort order: 

Position 




The 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! 

Popular posts from this blog

2023: Week 1 The Data Source Bank

2024: Week 1 - Prep Air's Flow Card

How to...Handle Free Text