Hi,
How could I find (for example) the third smallest value in a list of numbers even if there is duplicates. For example, LARGE and SMALL find the number but if I had numbers 1, 2, 2, 3, 4 and I use SMALL(Range, 3), then it gives 2. I want 3? RANK does not help either!
Any ways to do this?
TX
Find real n-th smallest/largest number
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Find real n-th smallest/largest number
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 3StarLounger
- Posts: 392
- Joined: 25 Jan 2010, 12:21
Re: Find real n-th smallest/largest number
Make a new range that just lists teh unique values and then get the small/large of this:
If your cells are in A1:A5, In B1 enter:
=IF(COUNTIF($A$1:A1,A1)=1,A1,"")
Then copy to B2:B5
Then use:
=SMALL(B1:B5,3)
Steve
If your cells are in A1:A5, In B1 enter:
=IF(COUNTIF($A$1:A1,A1)=1,A1,"")
Then copy to B2:B5
Then use:
=SMALL(B1:B5,3)
Steve
-
- Administrator
- Posts: 78487
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Find real n-th smallest/largest number
Or without an auxiliary column, you could use this array formula (confirm with Ctrl+Shift+Enter):
=SMALL(IF(MATCH(A1:A5,A1:A5,0)=ROW(A1:A5),A1:A5),3)
=SMALL(IF(MATCH(A1:A5,A1:A5,0)=ROW(A1:A5),A1:A5),3)
Best wishes,
Hans
Hans
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Find real n-th smallest/largest number
Awesome.
Thanks guys...both replies are great!!!
Thanks guys...both replies are great!!!
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Find real n-th smallest/largest number
Hans,HansV wrote:Or without an auxiliary column, you could use this array formula (confirm with Ctrl+Shift+Enter):
=SMALL(IF(MATCH(A1:A5,A1:A5,0)=ROW(A1:A5),A1:A5),3)
It seems like this formula only works if the list of numbers is in a column starting at row 1. It produces a #NUM error if the list is any other position on the sheet.
Cheers
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- Administrator
- Posts: 78487
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Find real n-th smallest/largest number
Correct. If the list starts elsewhere, let's say it's A10:A20, modify the formula as follows:
=SMALL(IF(MATCH(A10:A20,A10:A20,0)=ROW(A10:A20)-MIN(ROW(A10:A20))+1,A10:A20),3)
More general:
=SMALL(IF(MATCH(rng,rng,0)=ROW(rng)-MIN(ROW(rng))+1,rng),N)
where rng is the range of cells, and N is the position you want to return.
Don't forget to confirm with Ctrl+Shift+Enter.
Source: Formulas for Unique Data
=SMALL(IF(MATCH(A10:A20,A10:A20,0)=ROW(A10:A20)-MIN(ROW(A10:A20))+1,A10:A20),3)
More general:
=SMALL(IF(MATCH(rng,rng,0)=ROW(rng)-MIN(ROW(rng))+1,rng),N)
where rng is the range of cells, and N is the position you want to return.
Don't forget to confirm with Ctrl+Shift+Enter.
Source: Formulas for Unique Data
Best wishes,
Hans
Hans
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Find real n-th smallest/largest number
Perfect.
Cheers
Cheers
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.