Top 5 using range in column A that matches values range of column B

前端 未结 2 338
醉话见心
醉话见心 2021-01-17 05:33
[A]  [B]  [C]  [D]  [E]
ABC  DFC  20
DE   DE   12
     GF   11
     ABC  19
     DE   17
     DE   15
     XE   14
     ABC  10

I would like to put

相关标签:
2条回答
  • 2021-01-17 06:34

    In cell E1 and copied down:

    =IF(ROW(E1)>SUMPRODUCT(COUNTIF($B$1:$B$8,$A$1:$A$6)),"",LARGE(INDEX((COUNTIF($A$1:$A$6,$B$1:$B$8)>0)*$C$1:$C$8,),ROW(E1)))
    

    In cell D1 and copied down:

    =IF(E1="","",INDEX($B$1:$B$8,MATCH(E1,$C$1:$C$8,0)))
    

    Both formulas are regular formulas and do not require array entry. In both cases, adjust the B and C column references to fit your actual data. Don't use whole column references. If necessary, use dynamic named ranges for the column B and C range references

    EDIT: And just in case there are duplicates in the numeric values of the top five numbers for column C, use this formula instead in cell D1 and copy down:

    =IF(E1="","",INDEX($B$1:$B$8,SMALL(INDEX(($C$1:$C$8=E1)*ROW($C$1:$C$8),),COUNTIF($C$1:$C$8,"<>"&E1)+COUNTIF(E$1:E1,E1))))
    
    0 讨论(0)
  • 2021-01-17 06:36

    The newer AGGREGATE function can help retrieve the appropriate values as well as passing their associated row numbers to an INDEX function to retrieve the names.

    In E2:F2 as standard formulas,

    =INDEX(B:B, AGGREGATE(15, 6, ROW(B$1:INDEX(B:B, MATCH(1E+99, C:C)))/(C$1:INDEX(C:C, MATCH(1E+99, C:C))=F2), COUNTIF(F$2:F2, F2)))
    =AGGREGATE(14, 6, C$2:INDEX(C:C, MATCH(1E+99,C:C ))/ISNUMBER(MATCH(B$2:INDEX(B:B, MATCH(1E+99, C:C)), A$2:INDEX(A:A, MATCH("zzz", A:A)), 0)), ROW(1:1))
    

    Fill down for four more rows.

            

    Note that I've changed one of your values to demonstrate how duplicates are handled.

    0 讨论(0)
提交回复
热议问题