Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Percentage Difference Between Years

Hi Experts   What is the best way to calculate the Percentage Difference between the Years as shown in the same Data. I would like to plot the % diff in a line chart by Month Sample Data Mon...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  Anonymous ,

     

    Here are the steps you can follow:

    1. Select [2019] – [2022] – Transform – Unpivot Columns.

    2. Change the [Attribyte] format to Whole number..

    3. Create calculated column.

    Flag =
    var _max=MAXX(ALL('Table'),'Table'[Attribute])
    return
    IF(
        'Table'[Attribute]=_max,BLANK(),VALUE(RIGHT('Table'[Attribute],2)) +1 &"-"& VALUE(RIGHT('Table'[Attribute],2)))

    4. Create measure.

    Measure =
    var _current=
    SUMX(  FILTER(ALL('Table'),'Table'[Month]=MAX('Table'[Month])&&'Table'[Attribute]=MAX('Table'[Attribute])),[Value])
    var _next=
    SUMX(
    FILTER(ALL('Table'),'Table'[Month]=MAX('Table'[Month])&&'Table'[Attribute]=MAX('Table'[Attribute])+1),[Value])
    return
    DIVIDE(
        _current,_next)

    5. Result:

     

    Best Regards,

    Liu Yang

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