2024: Week 37 - Premier League recent form

Created by Carl Allchin

The final part of the Premier League results challenges involves trying to determine the teams' recent form. This is a common feature of sports tables so can you form with your data prep skills. 

This challenge can involve reusing previous logic you've formed over the last two week's challenges. Learning to reuse logic is useful too! If you haven't done the previous weeks, you may want to do those two challenges before this one. 

I'm going to give less clues as to the logic you need to follow this week as you're now familiar with the dataset and I want to see what you all come up with! 

Input

Like Week 36's challenge, let's use Week 35's Output as the data:


Requirements

  • Input the data
  • Recreate the logic to form a data set of:
    • Matchday
    • Team
    • Goals For (definition: goals scored by the team in the record)
    • Goals Against (definition: goals conceded by the team in the record)
    • Goal Difference (Goals For - Goals Against)
    • Points
  • Create calculations to capture the last 5 games results (the current matchday game and the previous four games)
    • The format should be:
      • [Result 4 games ago][Result 3 games ago][Result 2 games ago][Result 1 game ago][Current matchday result] as a string
      • If a game result hadn't occurred (i.e. only 3 games had been played as it's matchday 3, replace any non-results with a hyphen (-) character
  • Create a field to contain the Latest Result for the team 
    • [Goals For-Goals Against]
  • Create Running Totals in order of the match days per team for:
    • Goal Difference 
    • Points
  • Determine Position based on:
    • Points (High to Low)
    • Goal Difference  (High to Low)
    • Reverse Alphabetical Order of team name (I'm a Tottenham fan) 
  • Output the data

Output



7 data fields:
  • Matchday
  • Position
  • Team
  • Goal Difference (RT)
  • Points (RT)
  • Latest Result
  • Last 5 games
760 rows (761 incl. headers)

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 or LinkedIn 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