Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

TopN with duplicates

Hi guys, I would like to create a TOPN measure that sums up the revenues generated by the 2 most high-selling products. However, my table (a simplified version below) contains duplicates. Is it pos...
  • mahoneypat's avatar
    6 years ago

    Please try this expression in a measure to get your desired result.

     

    Top 2 Sum =
    VAR summary =
        ADDCOLUMNS (
            VALUES ( 'Table'[Product ID] ),
            "@total", CALCULATE ( SUM ( 'Table'[Revenue EURO] ) )
        )
    RETURN
        SUMX ( TOPN ( 2, summary, [@total], DESC ), [@total] )

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat