sum column of numbers based on id # and other possible criteria

cbcool

New Member
Joined
Nov 11, 2019
Messages
2
I am trying to do the following but cannot seem to wrap my head around it.



I have a workbook with multiple sheets. For what I am doing I have to pull information from one and compare it to another. It looks something like this:



Sheet 1

ABCDEF
1Game #CardsHome IDHome ScoreAway IDAway Score
21014521532
311115631511
41215811493
513116051474
61416241601
71514711621
816114921581
91715101565
1018115331452

<tbody>
</tbody>
Sheet 2

ABCD
1Team IDTeam NameFlightCards
2145Red12b
3147Blue12b
4149Green12b
5151Black12a
6153White12a
7156Orange12a
8158Silver12c
9160Purple12c
10162Yellow12c

<tbody>
</tbody>












On sheet 2, I am trying to count the number of cards for each team from sheet 1, however, I only need to count cards from the winning team or the home team in the event of a tie. So I need to compare the team id with the Home ID/Away ID and if it matches see if the team won, and if they did count if there was a card present or not.



So using team 145 - they played 2 games (game # 10 & 18). In game 10, 145 was the home team and they tied. So I would look to see if there was a card and there was not so I would return a 0 in cell D2. In game 18, 145 was the away team and lost the game. So I would also return a 0 in cell D2 even though a card was present in the game.



Team 149 played 2 games (12 & 16). Game 12, 148 won the game 3-1 but there were no cards so I would return a 0 in cell D4. Game 16, 149 won 2-1 and there was a card present so I would return a 1 in cell D4.



I have thousands of games to sort through with hundreds of teams so any help I can get would really be appreciated.
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,619
Office Version
  1. 2007
Platform
  1. Windows
Try this



=SUMPRODUCT((Sheet1!$C$2:$C$10=A2)*(Sheet1!$D$2:$D$10>=Sheet1!$F$2:$F$10)*(Sheet1!$B$2:$B$10>0))+SUMPRODUCT((Sheet1!$E$2:$E$10=A2)*(Sheet1!$F$2:$F$10>=Sheet1!$D$2:$D$10)*(Sheet1!$B$2:$B$10>0))
 

cbcool

New Member
Joined
Nov 11, 2019
Messages
2
That worked perfectly once I changed it to not count ties for the away teams. Thank you so much!

Try this



=SUMPRODUCT((Sheet1!$C$2:$C$10=A2)*(Sheet1!$D$2:$D$10>=Sheet1!$F$2:$F$10)*(Sheet1!$B$2:$B$10>0))+SUMPRODUCT((Sheet1!$E$2:$E$10=A2)*(Sheet1!$F$2:$F$10>=Sheet1!$D$2:$D$10)*(Sheet1!$B$2:$B$10>0))
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,619
Office Version
  1. 2007
Platform
  1. Windows
I'm glad to help you. Thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,550
Messages
5,625,450
Members
416,107
Latest member
AVaes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top