Limit the filter function

yomarcos

New Member
Joined
Aug 13, 2021
Messages
39
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,

I asked before in another thread how to show only the first value from a filter function and the solution I got here worked perfectly.
Now I need to show the first 5 values from a filter function. Does anyone have an idea how to do that?

Thank you!!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi,

Just extend the formula given earlier with a SEQUENCE so this

Excel Formula:
=index(filterformula,1)

becomes

Excel Formula:
=index(filterformula,SEQUENCE(5))

This formula will spil vertical to transpose the results horizontally

Excel Formula:
=index(filterformula,SEQUENCE(1,5))
 
Upvote 0
Hi,

Just extend the formula given earlier with a SEQUENCE so this

Excel Formula:
=index(filterformula,1)

becomes

Excel Formula:
=index(filterformula,SEQUENCE(5))

This formula will spil vertical to transpose the results horizontally

Excel Formula:
=index(filterformula,SEQUENCE(1,5))
This is getting me only the 1st value. Not the first 5.
I have tried with =sortn(filterformula, 5) and even though it changes the order of the values, it gives me only 5 of them
 
Upvote 0
This is getting me only the 1st value. Not the first 5.
I have tried with =sortn(filterformula, 5) and even though it changes the order of the values, it gives me only 5 of them
Strange, please check 2 things:
  1. type errors because in my test (see below) it works;
  2. does your filter has also blank results because then this will not work and it becomes difficult and will involve LET function (which you can't use on Google sheets)

Book1
JKLM
1Product CodeRowNr
2ID00032
3ID000332
4ID000143
5ID000256
6ID0003614
7ID0004715
8ID00048
9ID00049
10ID000510
11ID000611
12ID000612
13ID000713
14ID000314
15ID000315
16ID000116
17ID000217
18ID000318
19ID000319
20ID000320
21ID000321
22ID000322
23ID000323
24ID000324
25ID000725
26ID000326
27ID000327
28ID000128
29ID000229
30ID000330
31ID000431
32ID000432
33ID000433
34ID000534
35ID000635
36ID000636
37ID000737
Input
Cell Formulas
RangeFormula
M3:M7M3=INDEX(FILTER(K1:K37,J1:J37="ID0003"),SEQUENCE(5))
K2:K37K2=ROW()
Dynamic array formulas.
 
Upvote 0
Strange, please check 2 things:
  1. type errors because in my test (see below) it works;
  2. does your filter has also blank results because then this will not work and it becomes difficult and will involve LET function (which you can't use on Google sheets)

Book1
JKLM
1Product CodeRowNr
2ID00032
3ID000332
4ID000143
5ID000256
6ID0003614
7ID0004715
8ID00048
9ID00049
10ID000510
11ID000611
12ID000612
13ID000713
14ID000314
15ID000315
16ID000116
17ID000217
18ID000318
19ID000319
20ID000320
21ID000321
22ID000322
23ID000323
24ID000324
25ID000725
26ID000326
27ID000327
28ID000128
29ID000229
30ID000330
31ID000431
32ID000432
33ID000433
34ID000534
35ID000635
36ID000636
37ID000737
Input
Cell Formulas
RangeFormula
M3:M7M3=INDEX(FILTER(K1:K37,J1:J37="ID0003"),SEQUENCE(5))
K2:K37K2=ROW()
Dynamic array formulas.
I have just tried it and it doesn't work on Google sheets but it works on Excel.

1629889774372.png
 
Upvote 0
No expert on Google Sheets so with a little help from the ever expanding internet, google came up with
The formula =SEQUENCE(5) gives the same result as =ARRAYFORMULA(ROW(A1:A5)

With that we reversed the situation into: formula will work on Google Sheets but not in Excel.
 
Upvote 0
Nobody is a Google Sheets expert hahaha!!
The problem is not the SEQUENCE formula. =SEQUENCE(5) returns 1 2 3 4 5 in different rows. The problem is putting it inside the INDEX formula. The INDEX formula in Google sheets returns only ONE value
 
Upvote 0
I ended up using SORTN which sorts the values alphabetically which is not something I was trying to do, but it also limits the amount of values. I did have to TRANSPOSE/SORTN/TRANSPOSE to match what I needed though.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,391
Messages
6,171,824
Members
452,426
Latest member
cmachael

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