Faster formula than this ?

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
473
Office Version
  1. 365
Platform
  1. Windows
I have hundreds of formulas like this per sheet that finds 1st,2nd,3rd,4th last occurance, is there any faster formulas ?
Thanks

=IF(F4<>"",IFERROR(INDEX($AY$204296:$AY$525555,AGGREGATE(14,6,ROW($D$1:$D$525555)/($AW$204296:$AW$525555=F5)/($AA$204296:$AA$525555=F6),1)),""),"")

=IF(F4<>"",IFERROR(INDEX($AY$204296:$AY$525555,AGGREGATE(14,6,ROW($D$1:$D$525555)/($AW$204296:$AW$525555=F5)/($AA$204296:$AA$525555=F6),2)),""),"")

=IF(F4<>"",IFERROR(INDEX($AY$204296:$AY$525555,AGGREGATE(14,6,ROW($D$1:$D$525555)/($AW$204296:$AW$525555=F5)/($AA$204296:$AA$525555=F6),3)),""),"")

=IF(F4<>"",IFERROR(INDEX($AY$204296:$AY$525555,AGGREGATE(14,6,ROW($D$1:$D$525555)/($AW$204296:$AW$525555=F5)/($AA$204296:$AA$525555=F6),4)),""),"")
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
You may want to try the below:
Book1
BCDEFGHIJ
1
2Criteria 1 Criteria 2
3ab1ac7
42bb5
53ab3
64cb
75ab
86ac
97ab
10
Sheet1
Cell Formulas
RangeFormula
I3:I5I3=SORT(FILTER(D3:D9,B3&C3=E3:E9&F3:F9),,-1)
Dynamic array formulas.
 
Upvote 0
Thanks never knew about dynamic array formulas, have tested
=SORT(FILTER(D3:D9,"a"&"b"=E3:E9&F3:F9),,-1)
but it sorts by max number , instead of last to 1st occurance
 
Upvote 0
Change to

=SORT(FILTER(D3:D9,"a"&"b"=E3:E9&F3:F9),,1)
 
Upvote 0
tried that , that gets results min to max, i am trring to get last occurance to 1st occurance , so it searches column from last row to 1st row.
 
Upvote 0
Are you able to post some sample data?

In your original formula, you are using the Large Function within Aggregate? So would not that get the 1st, 2nd etc, largest occurance rather that the smallest? So my original solution looks at the array and returns the greatest number, ie 7 which is that last occurance and then put that at the top of the list. Excel will alway search from top to bottom, it is the function that will manipulate the search to show the result ie XMATCH has a parameter that to switch the search from the bottom of the list.

Book1
ABCDEFGH
2Criteria 1Criteria 2
3
4ab1ac7
52bb
63ab
74cb
85ab
96ac
107ab
Sheet2
Cell Formulas
RangeFormula
H4H4=XMATCH(B4&C4,E4:E10&F4:F10,0,-1)


So the Sort Function shows the largest (your 1st Large value) at the top.
 
Upvote 0
sorry cant post sample data , but my original formulas definatly get last occurance to 1st occurance

this gets last occurance =IF(F4<>"",IFERROR(INDEX($AY$204296:$AY$525555,AGGREGATE(14,6,ROW($D$1:$D$525555)/($AW$204296:$AW$525555=F5)/($AA$204296:$AA$525555=F6),1)),""),"")

this gets second last occurance=IF(F4<>"",IFERROR(INDEX($AY$204296:$AY$525555,AGGREGATE(14,6,ROW($D$1:$D$525555)/($AW$204296:$AW$525555=F5)/($AA$204296:$AA$525555=F6),2)),""),"")
 
Upvote 0
Without an XL2BB am not really following what you are doing but leveraging off @Skybluekid's post #2 and homing in your terminology of Last to First occurence, would this work for you ?

Excel Formula:
=CHOOSECOLS(SORT(FILTER(HSTACK(D3:D9,SEQUENCE(COUNTA(D3:D9))),B3&C3=E3:E9&F3:F9),2,-1),1)
 
Upvote 0
Book2.xlsx
ABCDEF
1red
2blue
3
467redblue
599redblue
6712
72
86redblue
97
108
1118
12
13
14
15
16
17
18
Sheet1
Cell Formulas
RangeFormula
A4A4=IF(F1<>"",IFERROR(INDEX($B$1:$B$20,AGGREGATE(14,6,ROW($B$1:$B$20)/($C$1:$C$20=F1)/($D$1:$D$20=F2),1)),""),"")
A5A5=IF(F1<>"",IFERROR(INDEX($B$1:$B$20,AGGREGATE(14,6,ROW($B$1:$B$20)/($C$1:$C$20=F1)/($D$1:$D$20=F2),2)),""),"")
A6A6=IF(F1<>"",IFERROR(INDEX($B$1:$B$20,AGGREGATE(14,6,ROW($B$1:$B$20)/($C$1:$C$20=F1)/($D$1:$D$20=F2),3)),""),"")
 
Upvote 0
Just reconfiguring post #8 to fit your data seems to work for me:
Excel Formula:
=CHOOSECOLS(SORT(FILTER(HSTACK(B4:B11,SEQUENCE(COUNTA(B4:B11))),F1&F2=C4:C11&D4:D11),2,-1),1)

Or using the multiply rather than concatenate method:
Excel Formula:
=CHOOSECOLS(SORT(FILTER(HSTACK(B4:B11,SEQUENCE(COUNTA(B4:B11))),(C4:C11=F1)*(D4:D11=F2)),2,-1),1)
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,904
Members
449,194
Latest member
JayEggleton

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