Forum Discussion

jayjani's avatar
jayjani
Helper I
6 years ago
Solved

YoY Calulation not working

Hello, I am trying to calculate YoY and QoQ for my data and tried various different techniques but to no avail. I am able to correctly mark Previous Year but whenever I try to calculate Sales data...
  • v-alq-msft's avatar
    6 years ago

    Hi, jayjani 

     

    I'd like to suggest you create a Date table. I created data to reproduce your scenario.

    Table:

    Calendar:

     

    Calendar = CALENDARAUTO()

     

     

    There is a relationship between two tables.

     

    You may a measure as follows.

     

    LY Sales1 = 
    IF(
        ISFILTERED('Calendar'[Date].[Year]),
        CALCULATE(
            SUM('Table'[Sales]),
            DATESYTD(SAMEPERIODLASTYEAR('Calendar'[Date]))
        )
    )
    
    LY Sales2 = 
    var _year = SELECTEDVALUE('Calendar'[Date].[Year])
    return
    CALCULATE(
        SUM('Table'[Sales]),
        FILTER(
            ALLSELECTED('Table'),
            YEAR('Table'[Date]) = _year-1
        )
    )

     

     

    Result:

     

    Best Regards

    Allan

     

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