Formula to return most repeated text in filtered data

mecerrato

Board Regular
Joined
Oct 5, 2015
Messages
174
Office Version
  1. 365
Platform
  1. Windows
Hi, I have the following formulas that returns the most repeated text in a range that ignores blanks as well but I need to adjust it to only test the visible cells as the data is filtered, can someone help me?

I am not sure which is better but both seem to work, can you help me choose the best one and help me so it only looks at the filtered data (visible cells)?
=INDEX(B22:B10000,MODE(IF(B22:B10000<>"",MATCH(B22:B10000,B22:B10000,0))))
=LOOKUP(1,0/FREQUENCY(0,1/(1+COUNTIF(B22:B10000,B22:B10000))),B22:B10000)
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
To modify the formulas to only consider visible cells when the data is filtered, you can use the SUBTOTAL function combined with AGGREGATE function. Here's how you can adjust both formulas:

For the first formula:

=INDEX(B22:B10000,MODE(IF(SUBTOTAL(3,OFFSET(B22:B10000,ROW(B22:B10000)-MIN(ROW(B22:B10000)),,1)), IF(B22:B10000<>"", MATCH(B22:B10000, B22:B10000, 0))))

For the second formula:

=LOOKUP(1,0/FREQUENCY(0,1/(1+SUBTOTAL(3,OFFSET(B22:B10000,ROW(B22:B10000)-MIN(ROW(B22:B10000)),,1)))),B22:B10000)


These modified formulas will now consider only the visible cells when the data is filtered. As for choosing the better formula, both are effective in finding the most repeated text in a range while ignoring blanks and considering only visible cells when filtered. You can choose either based on personal preference or compatibility with your existing setup.
 
Upvote 0
A non volatile way
Excel Formula:
=LET(r,B22:B10000,f,FILTER(r,MAP(r,LAMBDA(m,SUBTOTAL(103,m)))),INDEX(f,MODE(XMATCH(f,f))))
 
Upvote 0
For the second formula:

=LOOKUP(1,0/FREQUENCY(0,1/(1+SUBTOTAL(3,OFFSET(B22:B10000,ROW(B22:B10000)-MIN(ROW(B22:B10000)),,1)))),B22:B10000)

The above formula does not appear to return the correct results in all cases . . .
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,956
Members
449,096
Latest member
Anshu121

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