Forum Discussion

JEM_Systems's avatar
JEM_Systems
Helper I
3 years ago
Solved

function SAMEPERIODLASTYEAR() not working

Hi, I'm trying to apply a sameperiolastyear function but is not working, this is my DAX: 


Invoices Same Period Last Year =
 
 CALCULATE(
    SUM('Monthly Sales Evolution Invoices'[Sum of Amount]),
    SAMEPERIODLASTYEAR('Monthly Sales Evolution Invoices'[Date])
 )


is there something wrong?
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi JEM_Systems ,

     

    I suggest you to create a calendar table with continuous date by CALENDAR()/CALENDARAUTO() function.

    Calendar = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]))

    Measure:

    LY Sales = CALCULATE(SUM('Table'[Sales]),SAMEPERIODLASTYEAR('Calendar'[Date]))

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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

     

     

3 Replies

  • RMDNA's avatar
    RMDNA
    Solution Sage

    Hi JEM_Systems - we would need a lot more info than that. How specifically is it not working? What kind of error does it return? Providing screenshots would help

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi JEM_Systems ,

         

        I suggest you to create a calendar table with continuous date by CALENDAR()/CALENDARAUTO() function.

        Calendar = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]))

        Measure:

        LY Sales = CALCULATE(SUM('Table'[Sales]),SAMEPERIODLASTYEAR('Calendar'[Date]))

        Result is as below.

         

        Best Regards,
        Rico Zhou

         

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