Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Sum by grouped fields

Hello guys,   I have two tables (Model and Ocurrencies) and I wish to create two measures which sum the mileages of models by the unit field.  In addition, these two tables have a relationship. How...
  • v-yalanwu-msft's avatar
    4 years ago

    Hi, Anonymous ;

    You could create a measure as follows:

    Measure = 
    IF(ISINSCOPE('Model'[Model]), 
      CALCULATE( SUM('Model'[Mileage]),FILTER('Ocurrencies',[Month]=MAX('Ocurrencies'[Month]))),
      SUMX(SUMMARIZE('Ocurrencies',[Model],[Month],"1",SUM('Model'[Mileage])),[1]))

    The final output is shown below:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.