Forum Discussion

mwen90's avatar
mwen90
Helper III
4 years ago
Solved

Calculate Difference in Column

Hi, 

 

I have a list with the below columns (in image). I want to write a DAX where I take the highest Day No. and subtract it from the lowest Day No. . 

 

Not sure how to do this? Also, I have up to 50 levels. Is there a way to write the DAX to take the group of levels and take the lowest / highest values? 

 

Thanks for the help! 

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    mwen90 This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

    The pattern is:
    MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
    MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
    AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
    etc.

     

  • Thanks for the help, 

     

    Bit confused, we're not looking for an average but for the last item to be minused from the first, will average give me that?

     

    Secondly, what is the measure your pointing to at the end of this DAX? MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])

     

    Cheers,