Sumif but only last 6 occurrences

SHARPY1

Board Regular
Joined
Oct 1, 2007
Messages
183
I have this sumif function,
but this will sum about 50 occurrences of data in E329,
how do i adapt formula to just sumif last 6 occurrences??

=SUMIF(E2:E328,E329,I2:I328)

Any help appreciated
Cheers
 
Hi,

I have quite similar issue to the mentioned above, but not exactly the same, so I hope anyone will be able to help me resolve this problem.

My database are the NCAA matches, with winner name in column A and loser in column B. I want to calculate the number of wins of team from column A in previous 5 matches, so the formula should take into consideration that team can appear either in column A or B.

I would be really grateful if anyone can help me with this problem.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
It's very simple database, looks like this.

WINNER LOSER
696579
698676
708696
714749
696635
696738
747610
753696
754696
696675

<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>

So in the last row I would like to have winning percentage of team 696 from previous 5 matches - it should be 0.4 in this case.
 
Upvote 0
Maybe this (for all question):

Layout

Team nameTeam nameRating Result - 6Result - 5Result - shift 0Result win % - 5 both col
Wigan AthleticBolton Wanderers5 109180%
FulhamEverton4
Manchester CityTottenham Hotspur2
Wigan AthleticNewcastle United5
Manchester UnitedBolton Wanderers4
Tottenham HotspurChelsea1
ReadingBirmingham City4
Wigan AthleticDerby County2
NewcastleUnited Fulham4
Bolton WanderersManchester City4
Wigan AthleticPortsmouth1
Aston VillaSunderland1
Everton WestHam United1
Blackburn RoversWigan Athletic0
Wigan AthleticArsenal2
Manchester UnitedLiverpool2
Wigan AthleticArsenal4
Manchester UnitedAston Villa1
Wigan AthleticBlackburn Rovers2
Derby CountyFulham1
Birmingham CityManchester City1
Wigan AthleticWest Ham United0
PortsmouthWigan Athletic2
LiverpoolEverton4
ChelseaMiddlesbrough1
Wigan AthleticNewcastle United1
****************************************************************************************************
<colgroup><col width="100" style="width: 75pt; mso-width-source: userset; mso-width-alt: 3657;" span="2"> <col width="42" style="width: 32pt; mso-width-source: userset; mso-width-alt: 1536;"> <col width="17" style="width: 13pt; mso-width-source: userset; mso-width-alt: 621;"> <col width="50" style="width: 38pt; mso-width-source: userset; mso-width-alt: 1828;" span="2"> <col width="73" style="width: 55pt; mso-width-source: userset; mso-width-alt: 2669;"> <col width="121" style="width: 91pt; mso-width-source: userset; mso-width-alt: 4425;"> <tbody> </tbody>

Formulas

Code:
Use Ctrl+Shif+Enter to enter the formulas

In E2

=SUM(IF(ROW($C$2:$C$27)>=LARGE(IF($A$2:$A$27=$A$27,ROW($C$2:$C$27)),MIN(6,COUNTIF($A$2:$A$27,$A$27))),IF($A$2:$A$27=$A$27,$C$2:$C$27)))

In F2

=SUM(IF(ROW($C$2:$C$27)>=LARGE(IF($A$2:$A$27=$A$27,ROW($C$2:$C$27)),MIN(5,COUNTIF($A$2:$A$27,$A$27))),IF($A$2:$A$27=$A$27,$C$2:$C$27)))

In G2

=SUM(IF(ROW($C$2:$C$27)>=LARGE(IF($A$2:$A$27=$A$27,ROW($C$2:$C$27)),MIN(5,COUNTIF($A$2:$A$27,$A$27))),IF($A$2:$A$27=$A$27,IF($C$2:$C$27=0,1))))

In H2

=SUM(IF(ROW($C$2:$C$27)>=LARGE(IF(($A$2:$A$27=$A$27)+($B$2:$B$27=$A$27),ROW($C$2:$C$27)),MIN(5,COUNTIF($A$2:$A$27,$A$27)+COUNTIF($B$2:$B$27,$A$27))),IF($A$2:$A$27=$A$27,1)))/5

Markmzz
 
Upvote 0
It's very simple database, looks like this.

WINNER LOSER
696
579
698
676
708
696
714
749
696
635
696
738
747
610
753
696
754
696
696
675

<TBODY>
</TBODY>

So in the last row I would like to have winning percentage of team 696 from previous 5 matches - it should be 0.4 in this case.

Thanks for the clear sample and the actual outcome.

D1: 696 (a team of interest)

D2, control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(ISNUMBER(MATCH(ROW($A$2:$A$11),
    LARGE(IF($A$2:$A$11=D$1,ROW($A$2:$A$11)),
      ROW(INDIRECT("1:"&MIN(5,COUNTIF($A$2:$A$11,D$1))))),0)),1))/
 ROWS($A$2:$A$11)
 
Upvote 0
Hi Rumci,

Now with your data:

Layout

WINNERLOSER
696579
698676
708696
714749
696635
696738
747610
753696Last 5 games 696Last 5 games 696Last 5 games 696Last 5 games 696Last 5 games
754696WinWin/last 5 games 696Win/all games 696Win/all gamesWin 696/all games
69667530,600,430,300,40
********************************************************************************************************

<tbody>
</tbody>

Formulas

Code:
In C11 - use Ctrl+Shift+Enter to enter the formula

=SUM(IF(ROW($B$2:$B$11)>=LARGE(IF(($A$2:$A$11=$A$11)+($B$2:$B$11=$A$11),ROW($B$2:$B$11)),
MIN(5,COUNTIF($A$2:$A$11,$A$11)+COUNTIF($B$2:$B$11,$A$11))),IF($A$2:$A$11=$A$11,1)))

In D11 - use Enter to enter the formula

=$C11/5

In E11 - use Enter to enter the formula

=$C11/(COUNTIF($A$2:$A$11,$A$11)+COUNTIF($B$2:$B$11,$A$11))

In F11 - use Enter to enter the formula

=$C11/ROWS($A$2:$A$11)

In G11 - use Ctrl+Shift+Enter to enter the formula

=SUM(IF(ROW($B$2:$B$11)>=LARGE(IF($A$2:$A$11=$A$11,ROW($B$2:$B$11)),MIN(5,COUNTIF($A$2:$A$11,$A$11))),IF($A$2:$A$11=$A$11,1)))/ROWS($A$2:$A$11)

I hope that the formulas above helps to solve your problem.

Markmzz
 
Upvote 0
Hi Guys

Thanks to all the people who have tried to solve this issue. This thread was exactly what I was looking for. Although it has been more than a year since someone used this thread, I still hope to receive an answer

Unfortunately the provided solutions do not work for my excel 2007.
I wasn't really able to track the error, but in example for the code

=SUM(IF(ROW($C$2:$C$27)>=LARGE(IF($A$2:$A$27=$A$27,ROW($C$2:$C$27)),MIN(6,COUNTIF($A$2:$A$27,$A$27))),IF($A$2:$A$27=$A$27,$C$2:$C$27)))

there is no solution, excel gives #VALUE?. If I try =IF($A$2:$A$27=$A$27,ROW($C$2:$C$27) also #VALUE?

Hopefully someone is able to help me.
Also if you have an other solution, this would be fine for me. I am only looking for an answer to the initial question in this thread, as I am trying to generate a trend for the quality of soccer teams.

Thank you guys!
 
Upvote 0
Hi Guys

Thanks to all the people who have tried to solve this issue. This thread was exactly what I was looking for. Although it has been more than a year since someone used this thread, I still hope to receive an answer

Unfortunately the provided solutions do not work for my excel 2007.
I wasn't really able to track the error, but in example for the code

=SUM(IF(ROW($C$2:$C$27)>=LARGE(IF($A$2:$A$27=$A$27,ROW($C$2:$C$27)),MIN(6,COUNTIF($A$2:$A$27,$A$27))),IF($A$2:$A$27=$A$27,$C$2:$C$27)))

there is no solution, excel gives #VALUE?. If I try =IF($A$2:$A$27=$A$27,ROW($C$2:$C$27) also #VALUE?

Hopefully someone is able to help me.
Also if you have an other solution, this would be fine for me. I am only looking for an answer to the initial question in this thread, as I am trying to generate a trend for the quality of soccer teams.

Thank you guys!

You need to confirm this formula with control+shift+enter. That means: Press down the control and the shift keys at the same time while you hit the enter key.
 
Upvote 0
You need to confirm this formula with control+shift+enter. That means: Press down the control and the shift keys at the same time while you hit the enter key.


Thank you Aladin

I did this for sure, but I get now a different response --> #NAME?

Can't imagine what's the problem.

Thanks again for any help!
 
Upvote 0
You need to confirm this formula with control+shift+enter. That means: Press down the control and the shift keys at the same time while you hit the enter key.


Thank you Aladin

I did this for sure, but I get now a different response --> #NAME?

Can't imagine what's the problem.

Thanks again for any help!
 
Upvote 0

Forum statistics

Threads
1,214,390
Messages
6,119,235
Members
448,879
Latest member
VanGirl

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