Sumif ,but only upto where last 3 instances match

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
473
Office Version
  1. 365
Platform
  1. Windows
Hi i have added a imige for better understanding,
Would anyone have a formula to sum column C,
when G1 matches column A and H1 matches column B, but only the last 3 instances where they match.
So in example answer would be 14.
Thanks
1111.png
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
This one works

=SUMPRODUCT((ROW(A5:A21)=IFERROR(AGGREGATE(14,6,ROW(A5:A21)/(A5:A21=G1)/(B5:B21=H1),{1,2,3}),0))*C5:C21)

Hi would you have a formula for countif ,that would only count upto last 3 where possible for amount of times apple and mark match ?
 
Upvote 0
Try

=SUMPRODUCT((ROW(A5:A21)=IFERROR(AGGREGATE(14,6,ROW(A5:A21)/(A5:A21=G1)/(B5:B21=H1),{1,2,3}),0))*1)

edit:- I just edited the original formula without thinking about it, as soon as I clicked the button to post it, the simple version hit me

=MIN(COUNTIFS(A5:A21,G1,B5:B21,H1),3)
 
Upvote 0
Try

=SUMPRODUCT((ROW(A5:A21)=IFERROR(AGGREGATE(14,6,ROW(A5:A21)/(A5:A21=G1)/(B5:B21=H1),{1,2,3}),0))*1)

edit:- I just edited the original formula without thinking about it, as soon as I clicked the button to post it, the simple version hit me

=MIN(COUNTIFS(A5:A21,G1,B5:B21,H1),3)
Thank you
 
Upvote 0

Forum statistics

Threads
1,216,499
Messages
6,131,010
Members
449,613
Latest member
MedDash99

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