Home » excel » excel – how do you find the nth lowest number in an array when numbers repeat themselves?

excel – how do you find the nth lowest number in an array when numbers repeat themselves?

Posted by: admin April 23, 2020 Leave a comment

Questions:

I am trying to find the second lowest cost in this list. Clearly, it is $547, but when I put the formula in: =SMALL(F2:F31, 2) I get $488.00, and I am guessing this is because $488 repeats itself a number of times and so it is the second number in the list of numbers to be the smallest?

What formula should I put in to get the second smallest number, despite repeats?table

How to&Answers:

What is the purpose of this? The end result? Do you seek automation or this is adhoc?

If this is adhoc, you can do:

1. copy column with numbers
2. Paste copied column into new sheet
3. Use Remove Duplicates functionality (Data tab) on this column to remove repetitions
4. Use your formula

Also, you can do this with one formula :

=SMALL(F2:F31, COUNTIF(F2:F31, MIN(F2:F31)) + 1)

Answer:

As long as you only want the second smallest number, and you only have 2 digits of significant influence, you can do this fairly effectively without creating additional arrays of data, or using Array Formulas, as long as you can re-order from largest to smallest, instead of smallest to largest.

First, find the smallest number, which is simply:

=MIN(F:F)

Then, subtract 1 penny from that amount. We can now use price-is-right-rules searching to find the closest number, utilizing the next-best feature of the MATCH function, as follows:

=INDEX(F:F,MATCH(MIN(F:F)+0.01,F:F,-1))

This will take the smallest number in column F, and add .01 to it. Using -1 as the 3rd argument in the MIN function forces MIN to accept the next best alternative if this amount is not matched exactly.

Answer:

Only because I figure based on your last post we are headed this way. I would as I said in that post make a unique list of all your states and counties.

![enter image description here

Then building on @Andrew formula, which should be the one marked as correct, with COUNTIFS() as the k value in the SMALL():

=SMALL(IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F)),COUNTIFS(DATA!A:A,A2,DATA!B:B,B2,DATA!F:F,MIN(IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F))))+1)

This will give you a clean list of the second value.

Then to find the Insurance company that goes with the quote use:

=INDEX(DATA!E:E,MATCH(SMALL(IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F)),COUNTIFS(DATA!A:A,A2,DATA!B:B,B2,DATA!F:F,MIN(IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F))))+1),IF(A2=DATA!A:A,IF(B2=DATA!B:B,DATA!F:F)),0))

Put them in the second row. These are both Array formulas and will need to be confirmed with ctrl-shift-enter. Then they can be copied down as far as needed.