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.
 

DanteAmor

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

Forum statistics

Threads
1,078,437
Messages
5,340,277
Members
399,361
Latest member
Linford

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top