I have a list A1:A100 containing numbers. I know that if I enter a
formula =MODE(A1:A100) in B1, the most frequent number in the list is shown
in B1. If I want to know the second most frequent number in the list to be
stored in B2, what should I enter in B2? Thanks in advance.
Best Regards,
Sam
In B2, array enter the formula (enter with Ctrl-Shift-Enter) - all on one
line (take out any line breaks inserted by the mail reader programs):
=INDEX(ROW(INDIRECT("A"&MIN(A1:A100)&":A"&MAX(A1:A100))),MATCH(LARGE(FREQUENCY(A1:A100,ROW(INDIRECT("A"&MIN(A1:A100)&":A"&MAX(A1:A100)))),2),FREQUENCY(A1:A100,ROW(INDIRECT("A"&MIN(A1:A100)&":A"&MAX(A1:A100)))),FALSE))
I'm sure that there is an easier method, which will probably come to me
shortly after I post this....
HTH,
Bernie
MS Excel MVP
"Sam" <sam_w...@yahoo.com.hk> wrote in message
news:d21f1c$d6...@imsp212.netvigator.com...
=MODE(IF(A1:A100<>B1,A1:A100,""))
array entered
--
Regards,
Peo Sjoblom
"Bernie Deitrick" <deitbe @ consumer dot org> wrote in message
news:etyxNFAN...@TK2MSFTNGP09.phx.gbl...
Thanks, Peo.
Bernie
"Peo Sjoblom" <ter...@mvps.org> wrote in message
news:ukJY5NAN...@tk2msftngp13.phx.gbl...
There's got to be a simpler way, but after some adult beverages, this is what I
came up with:
This is an array formula and, after you type or paste it into the cell, hold
down <ctrl><shift> while hitting <enter> in order to *array-enter*. XL will
place braces {...} around the formula.
=MATCH(MATCH(LARGE(FREQUENCY(rng,ROW(INDIRECT(
MIN(rng)&":"&MAX(rng)))),2),FREQUENCY(rng,ROW(
INDIRECT(MIN(rng)&":"&MAX(rng)))),0),ROW(
INDIRECT(MIN(rng)&":"&MAX(rng))),0)
1. rng is a named range for which you may substitute A1:A100
2. The "2" in the middle of the second line denotes the 2nd most frequent
number. You may substitute any other number or a cell reference containing the
number n for the nth most frequent.
--ron
>>
>
>There's got to be a simpler way, but after some adult beverages, this is what I
>came up with:
>
>This is an array formula and, after you type or paste it into the cell, hold
>down <ctrl><shift> while hitting <enter> in order to *array-enter*. XL will
>place braces {...} around the formula.
>
>=MATCH(MATCH(LARGE(FREQUENCY(rng,ROW(INDIRECT(
>MIN(rng)&":"&MAX(rng)))),2),FREQUENCY(rng,ROW(
>INDIRECT(MIN(rng)&":"&MAX(rng)))),0),ROW(
>INDIRECT(MIN(rng)&":"&MAX(rng))),0)
>
>1. rng is a named range for which you may substitute A1:A100
>2. The "2" in the middle of the second line denotes the 2nd most frequent
>number. You may substitute any other number or a cell reference containing the
>number n for the nth most frequent.
>
>
>--ron
And I see that Peo came up with a much simpler method!
--ron
More elegant for the OP's problem. FWIW, it doesn't scale well for,
say, the 8th most frequently occurring number in a range RNG. That
requires MATCH(LARGE(FREQUENCY(..))) but with a means of resolving
different numbers that appear the same number of times. Finding the
N_th most frequently occurring number in RNG is given by the array
formula
=INDEX(RNG,MATCH(LARGE(FREQUENCY(RNG,RNG)
+(1-ROW(INDIRECT("1:"&(ROWS(RNG)+1)))
/(ROWS(RNG)+1)),N),FREQUENCY(RNG,RNG)
+(1-ROW(INDIRECT("1:"&(ROWS(RNG)+1)))
/(ROWS(RNG)+1)),0))
>On Sat, 26 Mar 2005 00:42:20 +0800, "Sam" <sam_w...@yahoo.com.hk> wrote:
And by the light of morning I see that this formula will only work for
integers. So forget it if your data set is not so limited, and use one of the
other posted options.
--ron