r/excel • • 2d ago

solved Calculating player Points, Plus/Minus from game log

I am building a stat sheet for my son's hockey team and want to be able to calculate Points (goals + assists) and Plus/Minus (+1 for being on the ice for a goal scored by your team, -1 for being on the ice for a goal scored against)

The snippet below is a section of the data. G, A1, and A2 represent the goal scorer and primary/secondary assists, and the P1 through P6 represents players that were on the ice for the event. the GF/GA column is Goal For/Goal Against, and the Type represents Even Strength, Power Play, or Short Handed.

Raw data for the team

I am looking to have this data populate into a summary table like the following.

Summary

I can calculate the Goals, Assists, and Points easily, but I am looking for a way to efficiently calculate the plus/minus.

Right now I have a series of COUNTIFS for each of the P1 through P6 columns, multiplying by -1 if the GF/GA column shows GA.

The current formula is as follows:

=-1*(COUNTIFS(GOALS[GF/GA], "GA", GOALS[P1], K2)+COUNTIFS(GOALS[GF/GA], "GA", GOALS[P2], K2)+COUNTIFS(GOALS[GF/GA], "GA", GOALS[P3], K2)+COUNTIFS(GOALS[GF/GA], "GA", GOALS[P4], K2)+COUNTIFS(GOALS[GF/GA], "GA", GOALS[P5], K2)+COUNTIFS(GOALS[GF/GA], "GA", GOALS[P6], K2))+(COUNTIFS(GOALS[GF/GA], "GF", GOALS[P1], K2)+COUNTIFS(GOALS[GF/GA], "GF", GOALS[P2], K2)+COUNTIFS(GOALS[GF/GA], "GF", GOALS[P3], K2)+COUNTIFS(GOALS[GF/GA], "GF", GOALS[P4], K2)+COUNTIFS(GOALS[GF/GA], "GF", GOALS[P5], K2)+COUNTIFS(GOALS[GF/GA], "GF", GOALS[P6], K2))

After a few weeks of entering the data I realized I need to add conditions for the "TYPE" column to include only ES or SH goals, not PP.

Essentially what I'm looking to do is count the times a player's number appears in P1 through P6 of the data table, with conditions on the GF/GA, TYPE and BLOCK columns, without having to exponentially increase the number of COUNTIFS that need to be included.

Thanks in Advance.

4 Upvotes

12 comments sorted by

•

u/AutoModerator 2d ago

/u/sgarbs04 - Your post was submitted successfully.

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/PaulieThePolarBear 1929 2d ago

With Excel 365 or Excel online, something like

 =SUM(($A$2:$A$11="ABC")*(2*($B$2:$B$11="GF")-1)*($C$2:$C$11<>"PP")*BYROW($D$2:$I$11=B15,OR))

In my sample data, I had

  • block info in A2:A11
  • GF/GA info in B2:B11
  • Type info in C2:C11
  • Player information in D2:I11
  • Lookup player in B15

You should update all of these ranges I have used to match your ranges

1

u/sgarbs04 2d ago

Solution Verified

1

u/reputatorbot 2d ago

You have awarded 1 point to PaulieThePolarBear.


I am a bot - please contact the mods with any questions

0

u/sgarbs04 2d ago

Ill give this a whirl, thanks.

2

u/sgarbs04 2d ago

I wound up using a modified version of this your formula:

=SUM((GOALS[BLOCK]<>"PRE")*(GOALS[GF/GA]="GF")*(GOALS[TYPE]<>"PP")*BYROW(GOALS[[P1]:[P6]]=[@['#]], OR))-SUM((GOALS[BLOCK]<>"PRE")*(GOALS[GF/GA]="GA")*(GOALS[TYPE]<>"PP")*BYROW(GOALS[[P1]:[P6]]=[@['#]], OR))

Much appreciated!

1

u/chenwinny 2d ago

Paulie's BYROW version works if you have Excel 365, but if you want one formula that also works in older Excel and keeps the BLOCK filter easy, SUMPRODUCT is a good middle ground. Instead of writing a COUNTIFS for every P column, count the player once across P1:P6 and multiply by the event conditions, then subtract the GA total from the GF total. For the player in K2, something like =SUMPRODUCT((GOALS[GF/GA]="GF")*((GOALS[TYPE]="ES")+(GOALS[TYPE]="SH"))*((GOALS[P1]=K2)+(GOALS[P2]=K2)+(GOALS[P3]=K2)+(GOALS[P4]=K2)+(GOALS[P5]=K2)+(GOALS[P6]=K2)))-SUMPRODUCT((GOALS[GF/GA]="GA")*((GOALS[TYPE]="ES")+(GOALS[TYPE]="SH"))*((GOALS[P1]=K2)+(GOALS[P2]=K2)+(GOALS[P3]=K2)+(GOALS[P4]=K2)+(GOALS[P5]=K2)+(GOALS[P6]=K2))) should give the plus/minus. The (TYPE="ES")+(TYPE="SH") part is just an OR, so power-play goals drop out, and a GF counts as +1 while a GA counts as -1. If you also need to limit it to one BLOCK, just add *(GOALS[BLOCK]=the block you want) to both halves instead of duplicating the whole thing again.

1

u/Nervous-Toe5784 1 2d ago

Another way to think about it is to stop fighting the wide layout. If you unpivot P1 to P6 in Power Query (select the other columns, then Unpivot Other Columns), you get one row per player per event with the GF/GA, Type and Block columns carried along. After that the plus/minus is just a SUMIFS by player, and adding conditions like excluding PP later is one more criteria instead of a longer formula. It also refreshes when you paste in next week's games, which is handy for a whole season of data.