Issue with index match function

Shweta

Well-known Member
Joined
Jun 5, 2011
Messages
514
Hi All,

I have a table which contains Name and scores of some students.


NameScore
Ajay Patwal17
Ankit Dhingra16
Beikunth19
Garima Gupta24
Gunwant Kaur26
Harsha-
Himanshu15
Irfan11
Kunal-
Mukul16
Prem-
Priyanka Bansal-
Rahul17
Sachin Sharma20
Stuti Johnson19
Sunaina-
Vishal Aggrawal26

<tbody>
</tbody>

I need to find out top 3 names. I am using below function for that.

Code:
=INDEX($A$2:$A$18,MATCH(LARGE($B$2:$B$18,{1;2;3}),$B$2:$B$18,0))
with CSE.

Problem with this function is, it is giving result as Gunwant Kaur, Gunwant Kaur and Garima Gupta.
However, it should be Gurwant Kaur, Vishal Aggarwal and Garima Gupta.

I know it is happening because of the match function as it returns the first value it matches but I don't know how to deal with it. Kindly suggest.

Thanks in advance!

Regards,
Shweta Jain
 
Last edited:

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.
This will give you the top 3 in no particular order.

Code:
=INDEX($A$2:$A$18,LARGE(IF($B$2:$B$18>=LARGE($B$2:$B$18,3),ROW($A$2:$A$18)-1),ROWS($A$2:A2)))

Use with CTRL + Shift + Enter
 
Upvote 0
Row\Col
A​
B​
C​
D​
1​
Name Score
3​
2​
Ajay Patwal 17
3​
3​
Ankit Dhingra 16Top PerformersTop Values
4​
Beikunth 19Gunwant Kaur
26​
5​
Garima Gupta 24Vishal Aggrawal
26​
6​
Gunwant Kaur 26Garima Gupta
24​
7​
Harsha -
8​
Himanshu 15
9​
Irfan 11
10​
Kunal -
11​
Mukul 16
12​
Prem -
13​
Priyanka Bansal -
14​
Rahul 17
15​
Sachin Sharma 20
16​
Stuti Johnson 19
17​
Sunaina -
18​
Vishal Aggrawal 26

In C2 just enter:

=COUNTIFS(B2:B18,">="&LARGE(B2:B18,MIN(C1,COUNT(B2:B18))))

In C4 control+shift+enter, not just enter, and copy down:

=IF($D4="","",INDEX($A$2:$A$18,SMALL(IF($B$2:$B$18=$D4,ROW($A$2:$A$18)-ROW($A$2)+1),COUNTIFS($D$4:D4,D4))))

In D4 just enter and copy down:

=IF(ROWS($D$4:D4)>$C$2,"",LARGE($B$2:$B$18,ROWS($D$4:D4)))
 
Upvote 0
Thanks for your quick response!

Aladin Akyurek: Your formula is working fine for me however I don't want top three scores, I only want top three names. Please suggest.

Regards,
Shweta Jain
 
Upvote 0
Thanks for your quick response!

Aladin Akyurek: Your formula is working fine for me however I don't want top three scores, I only want top three names. Please suggest.

Regards,
Shweta Jain

Row\Col
A​
B​
C​
1​
Name ScoreTop Performers
2​
Ajay Patwal 17Gunwant Kaur
3​
Ankit Dhingra 16Vishal Aggrawal
4​
Beikunth 19Garima Gupta
5​
Garima Gupta 24
6​
Gunwant Kaur 26
7​
Harsha -
8​
Himanshu 15
9​
Irfan 11
10​
Kunal -
11​
Mukul 16
12​
Prem -
13​
Priyanka Bansal -
14​
Rahul 17
15​
Sachin Sharma 20
16​
Stuti Johnson 19
17​
Sunaina -
18​
Vishal Aggrawal 26

In C2 control+shift+enter, not just enter, and copy down:

=IF(ROWS($C$2:C2)>COUNTIFS($B$2:$B$18,">="&LARGE($B$2:$B$18,MIN(3,COUNT($B$2:$B$18)))),"",INDEX($A$2:$A$18,SMALL(IF($B$2:$B$18=LARGE($B$2:$B$18,ROWS($C$2:C2)),ROW($B$2:$B$18)-ROW($B$2)+1),SUM(IF(LARGE($B$2:$B$18,ROW($B$2:B2)-ROW($B$2)+1)=LARGE($B$2:$B$18,ROWS($C$2:C2)),1)))))
 
Upvote 0
you could also adjust your initial formula like this, to use the rownumber as an "artificial tiebreaker":

Code:
=INDEX($A$2:$A$18,MATCH(LARGE([B]$B$2:$B$18-ROW($B$2:$B$18)/999999999[/B],{1;2;3}),[B]$B$2:$B$18-ROW($B$2:$B$18)/999999999[/B],0))

Not the cleanest solution, but it shouldn't run into any problems if you are not dealing with very accurate numbers (many decimal places) and/or a huge dataset.
 
Upvote 0

Forum statistics

Threads
1,216,729
Messages
6,132,383
Members
449,725
Latest member
Enero1

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