Looking up Top N using criteria
I forgot to mention that this solution will take into consideration any
ties for third place. In other words, if there are two or more products
tied for third place, all will be displayed.
In article ,
Domenic wrote:
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!
|