top N values

brycos

New Member
Joined
Dec 19, 2005
Messages
10
i have a relatively short list. i would like to easily capture the top N values within the list. i have setup two columns
columnJ columnK
=LARGE(I$29:I$63,1) =VLOOKUP($J65,$I$29:$J$63,2,0)
=LARGE(I$29:I$63,2) =VLOOKUP($J66,$I$29:$J$63,2,0)
... etc

problem is when i have two or more values in columnJ i get the same result in columnK. is there an easier way to avoid the following not nearly perfect code
=IF(VLOOKUP(J66,I$29:J$63,2,0)=K65,IF(VLOOKUP(J66,I$33:J$63,2,0)=K65,IF(VLOOKUP(J66,I$36:J$63,2,0)=K65,IF(VLOOKUP(J66,I$41:J$63,2,0)=K65,IF(VLOOKUP(J66,I$45:J$63,2,0)=K65,IF(VLOOKUP(J66,I$51:J$63,2,0)=K65,IF(VLOOKUP(J66,I$53:J$63,2,0)=K65,VLOOKUP(J66,I$56:J$63,2,0),VLOOKUP(J66,I$53:J$63,2,0)),VLOOKUP(J66,I$51:J$63,2,0)),VLOOKUP(J66,I$45:J$63,2,0)),VLOOKUP(J66,I$41:J$63,2,0)),VLOOKUP(J66,I$36:J$63,2,0)),VLOOKUP(J66,I$33:J$63,2,0)),VLOOKUP(J66,I$29:J$63,2,0))

bc
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
brycos said:
i have a relatively short list. i would like to easily capture the top N values within the list. i have setup two columns
columnJ columnK
=LARGE(I$29:I$63,1) =VLOOKUP($J65,$I$29:$J$63,2,0)
=LARGE(I$29:I$63,2) =VLOOKUP($J66,$I$29:$J$63,2,0)
... etc

problem is when i have two or more values in columnJ i get the same result in columnK.

...

The lookup functions are designed to return the first match, so you cannot retrieve multiple records having the same key value.

Adjust the ranges to suit your sheet's layout.
Construct Top N List.xls
ABCDEF
14
21
3NameScoreRankTop 4
4dawn234brian
5damon235greg
6jon253jon
7nate226dawn
8christine217damon
9greg322 
10brian351 
11
12
13
Data
! OTHEWISE, ERROR OF JavaScript OCCUR.</FONT></CENTER>

Formulas...

C4, copied down:

=RANK(B4,$B$4:$B$10)+COUNTIF($B$4:B4,B4)-1

D1: 4

which is N of Top N.

D2:

=MAX(IF(INDEX(B4:B10,MATCH(D1,C4:C10,0))=B4:B10,C4:C10))-D1

which needs to be confirmed with control+shift+enter (not just with enter).

D4, copied down:

=IF(ROW()-ROW($D$4)+1<=$D$1+$D$2,INDEX($A$4:$A$10,MATCH(ROW()-ROW($D$4)+1,$C$4:$C$10,0)),"")

or

=IF(ROWS($D$4:D4)<=$D$1+$D$2,INDEX($A$4:$A$10,MATCH(ROWS($D$4:D4),$C$4:$C$10,0)),"")
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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