Have a sheet with a lot of sports data...
Row 1 has the titles of each column. Below that is data of individual games. Here's an idea of what it looks like, simplified.
HomeTeam, AwayTeam, HomeGoals, AwayGoals, TotalGoals, Result
Bruins, Leafs, 3, 2, 5, HomeWin
Coyotes, Jets, 3, 3, 6, Tie
Panthers, Lightning, 2, 3, 5, AwayWin
Predators, Kings, 1, 4, 5, AwayWin
Bruins, Blues, 2, 2, 4, Tie
etc
So what I want to do is pull in the value of HomeGoals for the last x games from x team.
For example, let's say I have a 1000 rows of data, how do I best get the sum or average of HomeGoals in the Bruins (team) last 4 games as the home team - so the 4 most recent times they show up in column A?
Similarly, how would I count the amount of AwayWins (last column) in the Bruins last x home games? Like if I have the Bruins 10 most recent home games, I want to count the number of times AwayWin was the result.
The data is ordered from oldest to most recent (but I can flip if needed).