Forum Discussion

milkywaypowerbi's avatar
4 years ago
Solved

Difference between Multiple Columns in Matrix Presented as Rows

Hi,   I have the following matrix in powerbi with year as columns and values as rows.   Profit is a measure = Revenue - Cost   How do I calculate the profit difference between years and present...
  • Icey's avatar
    Icey
    4 years ago

    Hi milkywaypowerbi ,

     

    Try this:

    Profit Diff =
    VAR CurrentYear_ =
        MAX ( Sheet1[Year] )
    VAR PreviousYear_ =
        MAXX ( FILTER ( ALL ( Sheet1[Year] ), Sheet1[Year] < CurrentYear_ ), [Year] )
    VAR CurrentProfit_ = [Profit]
    VAR PreviousProfit_ =
        CALCULATE ( [Profit], FILTER ( ALL ( Sheet1 ), Sheet1[Year] = PreviousYear_ ) )
    VAR MinYear_ =
        CALCULATE ( MIN ( Sheet1[Year] ), ALL ( Sheet1 ) )
    RETURN
        IF ( CurrentYear_ <> MinYear_, CurrentProfit_ - PreviousProfit_ )
    

     

     

    Best Regards,

    Icey

     

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

  • Icey's avatar
    Icey
    4 years ago

    Hi milkywaypowerbi ,

     

    Just create another measure like so:

    Profit Diff 2 = SUMX(Sheet1,[Profit Diff])

     

     

    Best Regards,

    Icey

     

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