View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Domenic
 
Posts: n/a
Default Looking up Top N using criteria

Assumptions:

Source table...

A1:C1 contains Cust ID, Prod ID, and Revenue

A2:C7 contains your data

Results table...

F1:L1 contains Cust ID, TProd1, TRev1, etc.

F2:F6 contains 000011, 000012, 000013, 000014, and 000015

Formulas:

E2, copied down:

=IF(COUNTIF($A$2:$A$7,F2)3,SUM(IF(($A$2:$A$7=F2)* ($C$2:$C$7=LARGE(IF($A
$2:$A$7=F2,$C$2:$C$7),3)),1)),COUNTIF($A$2:$A$7,F2 ))

....confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

G2:

=IF(INT((COLUMNS($G2:G2)-1)/2)+1<=$E2,INDEX($B$2:$B$7,MATCH(LARGE(IF($A$2
:$A$7=$F2,$C$2:$C$7-ROW($C$2:$C$7)/10^10),INT((COLUMNS($G2:G2)-1)/2)+1),$
C$2:$C$7-ROW($C$2:$C$7)/10^10,0)),"")

....confirmed with CONTROL+SHIFT+ENTER

H2:

=IF(INT((COLUMNS($G2:H2)-1)/2)+1<=$E2,INDEX($C$2:$C$7,MATCH(LARGE(IF($A$2
:$A$7=$F2,$C$2:$C$7-ROW($C$2:$C$7)/10^10),INT((COLUMNS($G2:H2)-1)/2)+1),$
C$2:$C$7-ROW($C$2:$C$7)/10^10,0)),"")

....confirmed with CONTROL+SHIFT+ENTER

Select/highlight G2:H2. Then copy across and down or place cursor over
the lower right corner of H2, click, drag across, and drag down.

Hope this helps!



In article ,
"Roddd" wrote:

In workbook A, I have a unique list of customer IDs in column A:
Cust ID
1 000011
2 000012
3 000013
4 000014
5 000015

In workbook B, I have a bunch of product / revenue information related to
each customer. Each customer may have multiple rows of data on this
workbook, but each row would be a unique Cust & Prod ID combination:
Cust ID Prod ID Revenue
1 000013 ABC123 1,000
2 000011 ABC987 10,000
3 000014 ABC234 5,000
4 000014 ABC345 15,000
5 000011 ABC789 9,000
6 000014 ABC567 20,000

Back in Workbook A, I would like to populate columns B - G with the Top 3
revenue generating products and their associated revenue:

Cust ID TProd1 TRev1 TProd2 TRev2 TProd3 TRev3
1 000011 ABC987 10,000 ABC789 9,000
2 000012
3 000013 ABC123 1,000
4 000014 ABC567 20,000 ABC345 15,000 ABC234 5,000
5 000015

Any thoughts on getting this started? Thanks.