Forum Discussion
Anonymous
6 years agoNot applicable
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...
- 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
mahoneypat
Microsoft Employee
6 years agoPlease 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