Most frequently occurring visible text string in a filtered column

nibor

New Member
Joined
Jun 13, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
This formula returns #NA if the filtered list only contains one row:

=INDEX(B2:B10,MODE(IF(SUBTOTAL(3,OFFSET(B2:B10,ROW(B2:B10)-ROW(B2),0,1))>0,MATCH(B2:B10,B2:B10,0))))

(Sourced from: Find most frequently occurring text string in a VISIBLE or filtered)

Can anyone help with a formula that returns the most frequent value regardless of how many rows are visible after filtering?

Thanks!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Welcome to the MrExcel forum!

Try:

=INDEX(B2:B10,MODE(IF(SUBTOTAL(3,OFFSET(B2:B10,ROW(B2:B10)-ROW(B2),0,1))>0,MATCH(B2:B10,B2:B10,0)*{1,1})))
 
Upvote 0
Just for info: my digging suggests that IFERROR might be helpful, but what to use if there is an error is throwing me. I've tried this but it only returns the first value in the array:
=INDEX(B2:B10,MIN(IF(SUBTOTAL(3,OFFSET(B2,ROW(B2:B10)-ROW(B2),0)),ROW(B2:B10)-ROW(B2:B10)+1)))
 
Upvote 0
Maybe this would work for you:

Book1
ABCD
1Most common visible
2Banana5
3Cherry4
4Apple2
5Grape2
6Pomelo1
7Tangerine1
8Orange0
9
10List
11Apple
12Banana
14Banana
15Cherry
17Cherry
18Apple
21Pomelo
22Banana
23Banana
24Cherry
25Grape
26Grape
27Cherry
28Banana
30Tangerine
31
Sheet2
Cell Formulas
RangeFormula
C2:D8C2=LET(rng,A11:A30,rws,ROWS(rng),u,UNIQUE(rng),v,SUBTOTAL(103,OFFSET(rng,SEQUENCE(rws,,0),0,1)),arr,(TRANSPOSE(u)=rng)*v,freq,TRANSPOSE(MMULT(SEQUENCE(,rws,,0),arr)),tbl,CHOOSE({1,2},u,freq),s,SORT(tbl,2,-1),s)
Dynamic array formulas.


This formula creates a list of the unique values in the table, counts how many rows are visible for each value, then sorts the unique list by that number.
 
Upvote 0
Maybe this would work for you:

Book1
ABCD
1Most common visible
2Banana5
3Cherry4
4Apple2
5Grape2
6Pomelo1
7Tangerine1
8Orange0
9
10List
11Apple
12Banana
14Banana
15Cherry
17Cherry
18Apple
21Pomelo
22Banana
23Banana
24Cherry
25Grape
26Grape
27Cherry
28Banana
30Tangerine
31
Sheet2
Cell Formulas
RangeFormula
C2:D8C2=LET(rng,A11:A30,rws,ROWS(rng),u,UNIQUE(rng),v,SUBTOTAL(103,OFFSET(rng,SEQUENCE(rws,,0),0,1)),arr,(TRANSPOSE(u)=rng)*v,freq,TRANSPOSE(MMULT(SEQUENCE(,rws,,0),arr)),tbl,CHOOSE({1,2},u,freq),s,SORT(tbl,2,-1),s)
Dynamic array formulas.


This formula creates a list of the unique values in the table, counts how many rows are visible for each value, then sorts the unique list by that number.
it works fine. but i need each result separately to be used as reference in my next formula
 
Upvote 0
Just use an index into the sorted table (the "s" name):

Book1
ABCD
1Most common visibleIndex
2Banana1
3Cherry2
4Grape3
5
6
7
8
9
10List
11Apple
12Banana
14Banana
15Cherry
17Cherry
18Apple
21Pomelo
22Banana
23Banana
24Cherry
25Grape
26Grape
27Cherry
28Banana
30Tangerine
31
Sheet2
Cell Formulas
RangeFormula
C2:C4C2=LET(rng,A11:A30,ix,D2,rws,ROWS(rng),u,UNIQUE(rng),v,SUBTOTAL(103,OFFSET(rng,SEQUENCE(rws,,0),0,1)),arr,(TRANSPOSE(u)=rng)*v,freq,TRANSPOSE(MMULT(SEQUENCE(,rws,,0),arr)),tbl,CHOOSE({1,2},u,freq),s,SORT(tbl,2,-1),INDEX(s,ix,1))


Also be aware that in case of ties, you'll only get one value.
 
Upvote 0
Just use an index into the sorted table (the "s" name):

Book1
ABCD
1Most common visibleIndex
2Banana1
3Cherry2
4Grape3
5
6
7
8
9
10List
11Apple
12Banana
14Banana
15Cherry
17Cherry
18Apple
21Pomelo
22Banana
23Banana
24Cherry
25Grape
26Grape
27Cherry
28Banana
30Tangerine
31
Sheet2
Cell Formulas
RangeFormula
C2:C4C2=LET(rng,A11:A30,ix,D2,rws,ROWS(rng),u,UNIQUE(rng),v,SUBTOTAL(103,OFFSET(rng,SEQUENCE(rws,,0),0,1)),arr,(TRANSPOSE(u)=rng)*v,freq,TRANSPOSE(MMULT(SEQUENCE(,rws,,0),arr)),tbl,CHOOSE({1,2},u,freq),s,SORT(tbl,2,-1),INDEX(s,ix,1))


Also be aware that in case of ties, you'll only get one value.
thank you @Eric W
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,109
Members
453,021
Latest member
Justyna P

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