Rank / Index / Match

Thoron6

New Member
Joined
Oct 27, 2015
Messages
27
Morning all,

I have a long list of the example data below and would like to bring back the top 5 site names (based on highest number in "kWh" descending) where the manager is "Graham" and open / Closed is "Open".

Any help would be appreciated:

[TABLE="width: 372"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Manager[/TD]
[TD]Open / Closed[/TD]
[TD]kWh[/TD]
[/TR]
[TR]
[TD]Site 1[/TD]
[TD]Lee[/TD]
[TD]Open[/TD]
[TD]2,746[/TD]
[/TR]
[TR]
[TD]Site 2[/TD]
[TD]Graham[/TD]
[TD]Open[/TD]
[TD]2,458[/TD]
[/TR]
[TR]
[TD]Site 3[/TD]
[TD]Graham[/TD]
[TD]Closed[/TD]
[TD]1,643[/TD]
[/TR]
[TR]
[TD]Site 4[/TD]
[TD]Graham[/TD]
[TD]Closed[/TD]
[TD]4,312[/TD]
[/TR]
[TR]
[TD]Site 5[/TD]
[TD]Graham[/TD]
[TD]Open[/TD]
[TD]3,408[/TD]
[/TR]
[TR]
[TD]Site 6[/TD]
[TD]Graham[/TD]
[TD]Open[/TD]
[TD]580[/TD]
[/TR]
[TR]
[TD]Site 7[/TD]
[TD]Lee[/TD]
[TD]Open[/TD]
[TD]1,601[/TD]
[/TR]
[TR]
[TD]Site 8[/TD]
[TD]Lee[/TD]
[TD]Open[/TD]
[TD]890[/TD]
[/TR]
[TR]
[TD]Site 9[/TD]
[TD]Lee[/TD]
[TD]Open[/TD]
[TD]3,613[/TD]
[/TR]
[TR]
[TD]Site 10[/TD]
[TD]Lee[/TD]
[TD]Closed[/TD]
[TD]4,664[/TD]
[/TR]
[TR]
[TD]Site 11[/TD]
[TD]Brian[/TD]
[TD]Open[/TD]
[TD]4,255[/TD]
[/TR]
[TR]
[TD]Site 12[/TD]
[TD]Paula[/TD]
[TD]Open[/TD]
[TD]525[/TD]
[/TR]
[TR]
[TD]Site 13[/TD]
[TD]Brian[/TD]
[TD]Open[/TD]
[TD]3,529[/TD]
[/TR]
[TR]
[TD]Site 14[/TD]
[TD]Adrian[/TD]
[TD]Open[/TD]
[TD]3,986[/TD]
[/TR]
[TR]
[TD]Site 15[/TD]
[TD]Adrian[/TD]
[TD]Open[/TD]
[TD]2,335[/TD]
[/TR]
[TR]
[TD]Site 16[/TD]
[TD]Graham[/TD]
[TD]Open[/TD]
[TD]914[/TD]
[/TR]
[TR]
[TD]Site 17[/TD]
[TD]Adrian[/TD]
[TD]Open[/TD]
[TD]1,541[/TD]
[/TR]
[TR]
[TD]Site 18[/TD]
[TD]Phil[/TD]
[TD]Open[/TD]
[TD]4,026[/TD]
[/TR]
[TR]
[TD]Site 19[/TD]
[TD]Phil[/TD]
[TD]Open[/TD]
[TD]3,660[/TD]
[/TR]
[TR]
[TD]Site 20[/TD]
[TD]Phil[/TD]
[TD]Open[/TD]
[TD]3,628[/TD]
[/TR]
[TR]
[TD]Site 21[/TD]
[TD]Phil[/TD]
[TD]Closed[/TD]
[TD]1,506[/TD]
[/TR]
[TR]
[TD]Site 22[/TD]
[TD]Phil[/TD]
[TD]Open[/TD]
[TD]1,211[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Book1
ABCDGH
1NameManagerOpen / ClosedkWhgraham
2Site 1LeeOpen2,746open
3Site 2GrahamOpen2,4585
4Site 3GrahamClosed1,6434
5Site 4GrahamClosed4,312Top N kWhTop N Sites
6Site 5GrahamOpen3,4083408Site 5
7Site 6GrahamOpen5802458Site 2
8Site 7LeeOpen1,601914Site 16
9Site 8LeeOpen890580Site 6
10Site 9LeeOpen3,613
11Site 10LeeClosed4,664
12Site 11BrianOpen4,255
13Site 12PaulaOpen525
14Site 13BrianOpen3,529
15Site 14AdrianOpen3,986
16Site 15AdrianOpen2,335
17Site 16GrahamOpen914
18Site 17AdrianOpen1,541
19Site 18PhilOpen4,026
20Site 19PhilOpen3,660
21Site 20PhilOpen3,628
22Site 21PhilClosed1,506
Sheet1 (2)


G1: 5 (desired Top N)

In G2 control+shift+enter, not just enter:

=COUNTIFS(B2:B23,G1,C2:C23,G2,D2:D23,">="&LARGE(IF(B2:B23=G1,IF(C2:C23=G2,D2:D23)),MIN(G3,COUNTIFS(B2:B23,G1,C2:C23,G2))))

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

=IF(ROWS($G$6:G6)>$K$1,"",LARGE(IF($B$2:$B$23=$G$1,IF($C$2:$C$23=$G$2,$D$2:$D$23)),ROWS($G$6:G6)))

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

=IF($G6="","",INDEX($A$2:$A$23,SMALL(IF($B$2:$B$23=$G$1,IF($C$2:$C$23=$G$2,IF($D$2:$D$23=$G6,ROW($A$2:$A$23)-ROW($A$2)+1))),COUNTIFS($G$6:G6,G6))))
 
Upvote 0

Forum statistics

Threads
1,224,297
Messages
6,177,746
Members
452,797
Latest member
prophet4see

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