Forum Discussion

common763's avatar
common763
Helper III
6 years ago
Solved

Difference instead of Total in PowerBI Matrix

I cant seem to find a solution to this online.  Basically I have a matrix table that displays two columns and instead of showing the total all I want is to display the difference.  Not sure how to do...
  • v-lionel-msft's avatar
    v-lionel-msft
    6 years ago

    Hi common763 ,

     

    Please create such a measure.

     

    Measure = 
    VAR x = 
    CALCULATE(
        SUM(Sheet4[Number]),
        FILTER(
            ALLSELECTED(Sheet4),
            Sheet4[DATE] < MAX(Sheet4[DATE]) && Sheet4[FACILITY] = MAX(Sheet4[FACILITY])
        )
    )
    VAR y = 
    CALCULATE(
        SUM(Sheet4[Number]),
        FILTER( ALL(Sheet4), Sheet4[DATE] = MAX(Sheet4[DATE]) && Sheet4[FACILITY] = MAX(Sheet4[FACILITY]) )
    )
    RETURN
    IF(
        HASONEFILTER(Sheet4[DATE]),
        SUM(Sheet4[Number]),
        x-y
    )

     

     

     

     

    Best regards,
    Lionel Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.