Forum Discussion

Sunilrane's avatar
Sunilrane
New Member
4 years ago
Solved

How to calculate % Change

Hi everyone, I need some help to calculate percentage change of the following example pasted below   [All Periods] [$] CYTD Wks - 5   02/05/22 $1,452,541,355 CYTD Wks PY - 5    02/05/21...
  • v-jinweili-msft's avatar
    4 years ago

    Hi Sunilrane,

     

    It seems that there are only two columns in your table:

    So you may create two columns to extract the Date and the Type:

    Date =
    RIGHT ( [[All Periods]]], 8 )
    Type =
    VAR _findWks =
        FIND ( "Wks", [[All Periods]]] )
    RETURN
        LEFT ( [[All Periods]]], _findWks + 2 )

     

    Output:

     

    Then create a measure 

    Changed Percentage =
    VAR _current =
        SUM ( 'Table'[[$]]] )
    VAR _previous =
        CALCULATE (
            SUM ( 'Table'[[$]]] ),
            FILTER (
                ALL ( 'Table' ),
                [Type] = MAX ( 'Table'[Type] )
                    && YEAR ( [Date] )
                        = YEAR ( MAX ( 'Table'[Date] ) ) - 1
            )
        )
    RETURN
        DIVIDE ( _previous, ( _current - _previous ) )

    And change the format to Percentage

     

    The final output:

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