Forum Discussion

TechR21's avatar
TechR21
Helper V
3 years ago
Solved

Adding row with a calculation to matrix visual

Hi,   In powerbi I have a simple matrix visual : - subscriptionname as row - month as column - sum of costs as value     Im trying to find a way to add the following to this matrix (or ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi TechR21 ,

     

    I suggest you to create a Calendar table to help your calculation.

    Calendar =
    ADDCOLUMNS (
        CALENDARAUTO (),
        "Year", YEAR ( [Date] ),
        "Month", MONTH ( [Date] ),
        "YearMonth",
            YEAR ( [Date] ) * 100
                + MONTH ( [Date] ),
        "Month-Year", FORMAT ( [Date], "MMMM-YY" )
    )

    Data model:

    Measure:

    Percentage Change by Month =
    VAR _CURRENT =
        CALCULATE ( SUM ( 'Table'[Costs] ) )
    VAR _PREVIOUS =
        CALCULATE ( SUM ( 'Table'[Costs] ), PREVIOUSMONTH ( 'Calendar'[Date] ) )
    RETURN
        IF ( _CURRENT = BLANK (), BLANK (), DIVIDE ( _CURRENT - _PREVIOUS, _PREVIOUS ) )

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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