=SUM(IF(ISNUMBER(MATCH(ROW($A$2:$A$26),
LARGE(IF($A$2:$A$26=A27,ROW($A$2:$A$26)),
ROW(INDIRECT("1:"&C27))),0)),$C$2:$C$26))
sorry, may have confused you with columns,
here is correct version
Team Name column A
Team name column B
Rating column C
i.e. in formula cell currently :SUMIF(a2:a26,a27,c2:c26)
however in that column there may be several entries matching cell a27,
in this case Wigan Athletic there are 8 previous entries in column A,
i only want to sumif the last 6
Wigan Athletic Bolton Wanderers 5
Fulham Everton 4
Manchester City Tottenham Hotspur 2
Wigan Athletic Newcastle United 5
Manchester United Bolton Wanderers 4
Tottenham Hotspur Chelsea 1
Reading Birmingham City 4
Wigan Athletic Derby County 2
Newcastle United Fulham 4
Bolton Wanderers Manchester City 4
Wigan Athletic Portsmouth 1
Aston Villa Sunderland 1
Everton West Ham United 1
Blackburn Rovers Wigan Athletic 0
Wigan Athletic Arsenal 2
Manchester United Liverpool 2
Wigan Athletic Arsenal 4
Manchester United Aston Villa 1
Wigan Athletic Blackburn Rovers 2
Derby County Fulham 1
Birmingham City Manchester City 1
Wigan Athletic West Ham United 0
Portsmouth Wigan Athletic 2
Liverpool Everton 4
Chelsea Middlesbrough 1
Wigan Athletic Newcastle United 1 SUMIF(a2:a26,a27,c2:c26)
Hi, sorry to resurect a 4 year old post but I've found the sumif formula above to be exactly what I needed but I'm stuck on how to turn this into a countif formula.
I have a spreadsheet almost identical to the above, where I want to sum the score for a team but only for the past 5 occurrances.
I would also like to count the number of clean sheets for the same 5 occurances but I'm struggling to convert the formula from a sumif to a countif = 0
Thanks
Ben
Hi,
For the exhibit used, the OP wanted the sum of the last 6 occurances of Wigan Athletic, therefore the result would have been 10;
Wigan Athletic Portsmouth 1
Wigan Athletic Arsenal 2
Wigan Athletic Arsenal 4
Wigan Athletic Blackburn Rovers 2
Wigan Athletic West Ham United 0
Wigan Athletic Newcastle United 1
I would like to count the number of clean sheets (0) in the same selection of 6 occurances, which in this case would be 1 (see above)
Ben
=SUM(IF(ISNUMBER(MATCH(ROW($A$2:$A$26),
LARGE(IF($A$2:$A$26=A27,ROW($A$2:$A$26)),
ROW(INDIRECT("1:"&C27))),0)),($C$2:$C$26=0)+0))
=MIN(6,COUNTIF($A$2:$A$26,A27))
Hi,
Great, it worked perfectly.
Many thanks for the speedy response.
Ben