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

#### cbcool

##### New Member
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

 A B C D E F 1 Game # Cards Home ID Home Score Away ID Away Score 2 10 145 2 153 2 3 11 1 156 3 151 1 4 12 158 1 149 3 5 13 1 160 5 147 4 6 14 162 4 160 1 7 15 147 1 162 1 8 16 1 149 2 158 1 9 17 151 0 156 5 10 18 1 153 3 145 2

<tbody>
</tbody>
Sheet 2

 A B C D 1 Team ID Team Name Flight Cards 2 145 Red 12b 3 147 Blue 12b 4 149 Green 12b 5 151 Black 12a 6 153 White 12a 7 156 Orange 12a 8 158 Silver 12c 9 160 Purple 12c 10 162 Yellow 12c

<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.

### 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
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
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))

Replies
11
Views
273
Replies
0
Views
305
Replies
3
Views
319
Replies
9
Views
206
Replies
0
Views
260

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.

### Which adblocker are you using?

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

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