Need Top 3 from each group

SKV

Active Member
Joined
Jan 7, 2009
Messages
257
I have data having multiple groups and from time to time I am being asked to get top or bottom candidate from each group. Presently I have to do it manually for each group.
Is there a way to make this process automated??

Example of data set
Group Value
A 1
A 2
A 3
B 1
B 6
B 10

Desired Output for TOP 2 from each group
Group Value
A 1
A 2
B 1
B 6

Please suggest best method to do this.

If I use TOP then it gives the top from the data but not by each group
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Here a possibility
Assuming data from A1 to B7 with header as shown
D2 to D5 like next
<TABLE style="WIDTH: 48pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=64 border=0 x:str><COLGROUP><COL style="WIDTH: 48pt" width=64><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD class=xl24 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; WIDTH: 48pt; BORDER-BOTTOM: #d4d0c8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=64 height=17>A</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl24 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>A</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl24 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>B</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl24 style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; BORDER-BOTTOM: #d4d0c8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>B</TD></TR></TBODY></TABLE>

E2 =LARGE((A$2:A$7=D2)*(B$2:B$7),1)
E3 =LARGE((B$2:B$7)*(A$2:A$7=D3),2)
E4 =LARGE((B$2:B$7)*(A$2:A$7=D4),1)
E5 =LARGE((B$2:B$7)*(A$2:A$7=D5),2)

F2 =SMALL(IF((A$2:A$7=D2)*(B$2:B$7)<>0,(A$2:A$7=D2)*(B$2:B$7),""),1)
F3 =SMALL(IF((A$2:A$7=D3)*(B$2:B$7)<>0,(A$2:A$7=D3)*(B$2:B$7),""),2)
F4 =SMALL(IF((A$2:A$7=D4)*(B$2:B$7)<>0,(A$2:A$7=D4)*(B$2:B$7),""),1)
F5 =SMALL(IF((A$2:A$7=D5)*(B$2:B$7)<>0,(A$2:A$7=D5)*(B$2:B$7),""),2)

All formulas to be confirmed with CONTROL + SHIFT + ENTER as area formula

²
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,613
Members
449,090
Latest member
vivek chauhan

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