Forum Discussion

dezzat's avatar
dezzat
New Member
8 years ago
Solved

How to add grouping in Measures

I have created this Measure statement:

 

Generated Energy (KWH) = CALCULATE(max(Readings[Reading]),Readings[Measurement Point Description]="Generated KWH") - CALCULATE(min(Readings[Reading]),Readings[Measurement Point Description]="Generated KWH")

 

But also I need to add grouping to this Measure "Generated Energy (KWH)" to be calculated Group by Specific Field  

  • Hi dezzat,


     

    I need to add grouping to this Measure "Generated Energy (KWH)" to be calculated Group by Specific Field  



    try this:

    Generated Energy (KWH) = 
    CALCULATE((
       CALCULATE(max(Readings[Reading]),Readings[Measurement Point Description]="Generated KWH") - 
       CALCULATE(min(Readings[Reading]),Readings[Measurement Point Description]="Generated KWH")
      ); //your calculation
    ALLEXCEPT(Readings;Readings[Specific_Field]) // Group field
    )//top level calculate

     ... and Merry Christmas.

    Best regs

2 Replies

  • McCow's avatar
    McCow
    Icon for Resolver III rankResolver III

    Hi dezzat,


     

    I need to add grouping to this Measure "Generated Energy (KWH)" to be calculated Group by Specific Field  



    try this:

    Generated Energy (KWH) = 
    CALCULATE((
       CALCULATE(max(Readings[Reading]),Readings[Measurement Point Description]="Generated KWH") - 
       CALCULATE(min(Readings[Reading]),Readings[Measurement Point Description]="Generated KWH")
      ); //your calculation
    ALLEXCEPT(Readings;Readings[Specific_Field]) // Group field
    )//top level calculate

     ... and Merry Christmas.

    Best regs

  • v-ljerr-msft's avatar
    v-ljerr-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi dezzat,

     

    Have you tried the solution provided by McCow above? Does it work in your scenario? If it works, could you accept it as solution to close this thread?

     

    If you still have any question on this issue, feel free to post here. :smileyhappy:

     

    Regards