Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Using SUMX twice within GROUPBY expression

Unit Category Score Weight Unit A X 5 2 Unit A Y 10 3 Unit A Z 15 2 Unit B X 1 7 Unit B Z 2 9 Unit C W 4 11   Essentially, what I want to do i...
  • smpa01's avatar
    4 years ago

    Anonymous  try this 

     

    Measure =
    VAR _sum =
    SUMX ( tbl, tbl[score] * tbl[weight] )
    VAR _count =
    CALCULATE ( SUM ( tbl[weight] ), ALLEXCEPT ( tbl, tbl[unit] ) )
    RETURN
    DIVIDE ( _sum, _count )