Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Year to Date Percentage Change Calculation

I want to show the year to date % change as a line on my chart. I want to show this only for the months in 2024 and my reference data is December 2023. The source table shows the revenue derived from...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous 

     

    I made some changes to the code for the new table.

     

    EarlyTotal = 
    var CurrentYear = CALCULATE(MAX('Table'[Date]), ALL('Table'))
    var earlyMaxDate = CALCULATE(MAX('Table'[Date]), FILTER(ALL('Table'), YEAR('Table'[Date]) = YEAR(CurrentYear) - 1 ))
    var EarlyYearTotal = 
        CALCULATE(
            SUM('Table'[ Amount]), 
            FILTER(
                ALL('Table'), 
                YEAR('Table'[Date]) = YEAR(CurrentYear) - 1 
                && 
                MONTH('Table'[Date]) = MONTH(earlyMaxDate)
            )
        )
    RETURN SUMMARIZE('Table', "EarlyYearTotal", EarlyYearTotal)

     

    You can check it out.

     

    Regards,

    Nono Chen

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