Array formula with top x results

Charles Bushby

New Member
Joined
Aug 10, 2005
Messages
42
Hi,

I need to use an array formula in Excel to summarise data from a table. The csv table is at the bottom of this posting. I want to summarise the top 5 clients (i.e. excludes Administration in Type field) where the hours are greater than zero and Invoiced is zero. My summary should look like this:

Top 5 uninvoiced
Work, Hours
Client L, 12
Client K, 8

Using an array formula I can successfully extract the hours but my array for the Work pulls out the wrong clients (namely Clients F and E). This is because the formula dumps the first clients with 12 and 8 hours. I therefore need a more complex formula that select the correct clients per the top para. above.

Any help with this would be much appreciated.

Charles Bushby

Work,Type,Hours,Invoiced
Client A,Client,60,7500
Client B,Client,5,10
Client C,Client,2,500
Client E,Client,8,900
Administration,Administration,31,
Client F,Client,12,500
Client G,Client,10,800
Client H,Client,12,650
Client I,Client,10,600
Client J,Client,10,750
Client K,Client,8,
Client L,Client,12,
Client D,Client,12,1000
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Row\Col
A​
B​
C​
D​
E​
F​
G​
1​
Top
5
2​
invoiced
0
3​
Type
client
4​
Adjusted
2
5​
WorkTypeHoursInvoicedWorkHours
6​
Client AClient
60​
7500​
Client L
12​
7​
Client BClient
5​
10​
Client K
8​
8​
Client CClient
2​
500​
9​
Client EClient
8​
900​
10​
AdministrationAdministration
31​
11​
Client FClient
12​
500​
12​
Client GClient
10​
800​
13​
Client HClient
12​
650​
14​
Client IClient
10​
600​
15​
Client JClient
10​
750​
16​
Client KClient
8​
17​
Client LClient
12​
18​
Client DClient
12​
1000​

<tbody>
</tbody>


In G4 control+shift+enter, not just enter:
Rich (BB code):

=SUM(COUNTIFS(B6:B18,G3,D6:D18,{"",0},C6:C18,">="&LARGE(IF($B$6:$B$18=G3,
  IF(D6:D18=G2,C6:C18)),MIN(G1,SUM(IF(B6:B18=G3,IF(D6:D18=G2,1)))))))<strike></strike>

In F6 control+shift+enter, not just enter, and copy down:
Rich (BB code):

=IF($G6="","",INDEX($A$6:$A$18,SMALL(IF($B$6:$B$18=$G$3,
  IF($D$6:$D$18=$G$2,IF($C$6:C$18=G6,ROW($C$6:C$18)-ROW($C$6)+1))),
  COUNTIFS($G$6:G6,G6))))<strike></strike>

In G6 control+shift+enter, not just enter, and copy down:
Rich (BB code):

=IF(ROWS($G$6:G6)<=$G$4,LARGE(IF($B$6:$B$18=$G$3,
  IF($D$6:$D$18=$G$2,$C$6:$C$18)),ROWS($G$6:G6)),"")<strike></strike>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,082
Messages
6,128,717
Members
449,464
Latest member
againofsoul

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