Sumproducts

fifaclub

New Member
Joined
Apr 5, 2011
Messages
1
Hi! I will very much appreciate any help on this

I have a list of matches in a season in Premiership, the list has four columns - Home Team (A), Away Team (B), Home Team Goals (C), Away Team Goals (D).

I want to add a column next to each game that sums the goals scored in the previous five matches by the host team, no matter if the team played home or away.

If the current match is in Row 55 Using Sumproduct I reached the following formula "=SUMPRODUCT(($A$2:54=A55)*($C$2:C54)+(($B$2:B54=A55)*($D$2:D54)))" which gives me the sum of the goals in all previous matches. My question is how can I limit this to the last five games only.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
hehe, sorry about that :biggrin:

okay, try this:
=SUMPRODUCT(
(OFFSET($A$2,LARGE(IF(($A$2:A54=A55)+($B$2:B54=A55),ROW($A$2:A54),FALSE),5)-2,0):A54=A55)
*(OFFSET($C$2,LARGE(IF(($A$2:A54=A55)+($B$2:B54=A55),ROW($A$2:A54),FALSE),5)-2,0):C54)
+(OFFSET($B$2,LARGE(IF(($A$2:A54=A55)+($B$2:B54=A55),ROW($A$2:A54),FALSE),5)-2,0):B54=A55)
*(OFFSET($D$2,LARGE(IF(($A$2:A54=A55)+($B$2:B54=A55),ROW($A$2:A54),FALSE),5)-2,0):D54))
Ctrl+Shift+Enter

or, if you would prefer to use two columns:

Cell E55:
=LARGE(IF(($A$2:A54=A55)+($B$2:B54=A55),ROW($A$2:A54),FALSE),5)
Ctrl+Shift+Enter

Cell F55:
=SUMPRODUCT(
(OFFSET($A$2,E55-2,0):A54=A55)
*(OFFSET($C$2,E55-2,0):C54)
+(OFFSET($B$2,E55-2,0):B54=A55)
*(OFFSET($D$2,E55-2,0):D54))
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,319
Members
452,905
Latest member
deadwings

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
Back
Top