Filter function with dynamic number of rows

Natit

Board Regular
Joined
Jan 22, 2012
Messages
50
Office Version
  1. 365
Platform
  1. Windows
Hi,
Here is my filter function.
=FILTER('gil2'!$A$2:$D$37,ISNUMBER(MATCH('gil2'!$C$2:$C$37,'gil2'!$M$8:$O$8,0)))
It works fine, but I would like it to be dynamic so the last row will be a result of "counta" or any other counting function instead a fix number (in the function here it is 37).
TIA
Nati
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Some sample data would have been useful.
One can use XLOOKUP to return a range.

Made a silly sample to showcase:
Book1
ABCDEFGH
1
2as5zy5
3fd4zu0
4de87zlm3
5ef6zo7
6dg4
7eh12
8zy5
9wt1
10zu0
11fk50
12zlm3
13fp5
14zo7
15zzzzn5
16w,8
Sheet1
Cell Formulas
RangeFormula
F2:H5F2=FILTER(A2:XLOOKUP("Ω",A:A,C:C,,-1,2),A2:XLOOKUP(99^99,C:C,A:A,,-1,2)="z")
Dynamic array formulas.
 
Upvote 0
Hi,
Thx for youe answer.
I'm adding my test table.
My question stays the same.
And I will add another one.
Is ther an option that thru the filte function I will show differnt (A,B,E,H...) columns and not only a sequence
Thx again
Nati


Filter_question.xlsx
ABCDEFGHIJKLMNOP
1itemdescriptionprice codeinventaritemdescriptionprice codeinventarunit group aunit group bunit group c
21893cat11100101893cat1110010aa1bb1cc1
32228cat21100202228cat2110020aa2bb2
42358cat31234302933cat17701043aa3
52562cat41234302743cat18701055
62640cat51234302817cat19701017
72656cat61234292900cat20701018data table
88011cat71273704019cat26970163aa1110070109701
98513cat81273604047cat27970154aa212348563
107118cat91273504097cat28970119aa39981
115723cat101111564154cat29970170bb112739010
124328cat11111157bb211111555
137010cat12155573cc16591
141538cat13155534
151111cat14659143
164444cat15659119
175555cat16659131
182933cat17701043
192743cat18701055
202817cat19701017
212900cat20701018
222914cat21856343
232936cat22856323
242945cat23856345
252960cat24856324
261544cat25901052
274019cat26970163
284047cat27970154
294097cat28970119
304154cat29970170
319311cat30998125
329412cat31998127
338317cat32998154
344156cat33998816
354188cat34998815
364195cat35998890
gil2
Cell Formulas
RangeFormula
F2:I11F2=LET( row_num,COUNTA($A:$A), FILTER($A$2:$D$37,ISNUMBER(MATCH($C$2:$C$37,$M$8:$O$8,0))))
Dynamic array formulas.
 
Upvote 0
EDITED: forgot to add the filter arguments before.

in [F2], try
Excel Formula:
=LET(
Cls,XLOOKUP(F1:I1,A1:D1,COLUMN(A1:D1)),
Arg,ROW(A2:XLOOKUP(99^99,A:A,A:A,,-1,2)),
Arr_2,C2:XLOOKUP(99^99,C:C,C:C,,-1,2),
Incl,ISNUMBER(MATCH(Arr_2;$M$8:$O$8;0)),
Arr,INDEX(A:D,Arg,Cls),FILTER(Arr,Incl))
 
Last edited:
Upvote 0
With XL2BB
[
MR Excel Dynamic filter arrays.xlsx
ABCDEFGHIJKLMNO
1itemdescriptionprice codeinventarprice codedescriptioninventaritemunit group aunit group bunit group c
21893cat11100101100cat1101893aa1bb1cc1
32228cat21100201100cat2202228aa2bb2
42358cat31234307010cat17432933aa3
52562cat41234307010cat18552743
62640cat51234307010cat19172817
72656cat61234297010cat20182900data table
88011cat71273709701cat26634019aa1110070109701
98513cat81273609701cat27544047aa212348563
107118cat91273509701cat28194097aa39981
115723cat101111569701cat29704154bb112739010
124328cat11111157bb211111555
137010cat12155573cc16591
141538cat13155534
151111cat14659143
164444cat15659119
175555cat16659131
182933cat17701043
192743cat18701055
202817cat19701017
212900cat20701018
222914cat21856343
232936cat22856323
242945cat23856345
252960cat24856324
261544cat25901052
274019cat26970163
284047cat27970154
294097cat28970119
304154cat29970170
319311cat30998125
329412cat31998127
338317cat32998154
344156cat33998816
354188cat34998815
364195cat35998890
Sheet1
Cell Formulas
RangeFormula
F2:I11F2=LET( Cls,XLOOKUP(F1:I1,A1:D1,COLUMN(A1:D1)), Rws,ROW(A2:XLOOKUP(99^99,A:A,A:A,,-1,2)), Arr,C2:XLOOKUP(99^99,C:C,C:C,,-1,2), Incl,ISNUMBER(MATCH(Arr,$M$8:$O$8,0)), Res,INDEX(A:D,Rws,Cls),FILTER(Res,Incl))
Dynamic array formulas.
 
Upvote 0
Solution
IT works fine ofcourse.
But, I Have a question, and sorry if it sound rude.
Do I need this complicated formula in order just to put the number of rows (which I found with the COUNTA function)?
 
Upvote 0
Your COUNTA includes the header and returns a single number. My "Rws" part, returns all row number from row 2 until the end of the range.
Could be using COUNTA with SEQUENCE I suppose.
Excel Formula:
=LET(
Cols,XLOOKUP(F1:I1,A1:D1,COLUMN(A1:D1)),
Cnt,COUNTA(A:A)-1,
Rws,SEQUENCE(Cnt,,2,1),
Arr,C2:XLOOKUP(99^99,C:C,C:C,,-1,2),
Incl,ISNUMBER(MATCH(Arr,$M$8:$O$8,0)),
Res,INDEX(A:D,Rws,Cols),FILTER(Res,Incl))
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,199
Members
449,072
Latest member
DW Draft

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