Forum Discussion

DiepNhiep's avatar
DiepNhiep
Frequent Visitor
2 years ago
Solved

PeriodOverPeriod with Date slicer

Hi, I would like to get help with the Measure of custom period and date slicer. I want to show the table with this information, for example

 

Date slicer in report to be set: May 3rd 2023 to May 25th 2023

Table

Revenue (May.03.2023 to May.25.2023)

Previous Period Revenue (May.03.2022 to May.25.2022)

%Change between these two metrics


I have been using the common used SAMEPERIODLASTYEAR and it works perfectly if I chose the Date slicer has 2022. But if I only choose as the example above, it does not work. Could any one help me with this one please? Thank you so much!

  • Hi DiepNhiep 
    you can try with DATEADD() to calculted previous year record of same period.
    Measure=
    Var Previous sales = CALCULATE(SUM(Table[Sales]),DATEADD('Calendar'[Date],-1,YEAR))
    Var Current sales= CALCULATE(SUM(Table[Sales]),DATEADD('Calendar'[Date],0,YEAR))
    Return Divide((Current Sales-Previous sales),Previous Sales)



     

4 Replies

  • Uzi2019's avatar
    Uzi2019
    Icon for Community Champion rankCommunity Champion

    Hi DiepNhiep 
    you can try with DATEADD() to calculted previous year record of same period.
    Measure=
    Var Previous sales = CALCULATE(SUM(Table[Sales]),DATEADD('Calendar'[Date],-1,YEAR))
    Var Current sales= CALCULATE(SUM(Table[Sales]),DATEADD('Calendar'[Date],0,YEAR))
    Return Divide((Current Sales-Previous sales),Previous Sales)



     

    • DiepNhiep's avatar
      DiepNhiep
      Frequent Visitor

      Hi Uzi2019 , 

      It is still not working if I do not choose the Date slicer that including last year...

      For example above, if I choose Date slicer to be within May 2023, the Previous Sales as an independent measure would not appear. I want the Previous Sales as a measure also 😉 Thank youu

      • Uzi2019's avatar
        Uzi2019
        Icon for Community Champion rankCommunity Champion

        hi DiepNhiep 
        you can create seperate measure for Prev Sales.

        and create seperate measure for %Change.
        if it does not help then please share the screen shot of what value you are getting and what value you want.