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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,059
Office Version
2007
Platform
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
11,059
Office Version
2007
Platform
Windows
I'm glad to help you. Thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,095,215
Messages
5,443,136
Members
405,218
Latest member
uxhptmtq

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top