Forum Discussion

Jackisover's avatar
Jackisover
Icon for Advocate I rankAdvocate I
2 years ago
Solved

Evolution rate for the current period

Hello, I have daily datas, since 2022 until this year, a few days ago.  I would like to be able to display my daily datas, for my current year but also to see the previous year.     My pro...
  • MFelix's avatar
    2 years ago

    Hi Jackisover ,

     

    If you add a column with the identification of the previous year you can have that value.

     

    In the Calendrier table add the following column:

    IsPast = 
    VAR LastSaleDate = MAX ( 'Data test'[Date] )
    VAR LastSaleDatePY = EDATE ( LastSaleDate, -12 )
    RETURN
        'calendrier'[Date] <= LastSaleDatePY

    Now change your measure to the following code:

    Volume N-1 VAR = 
    
    calculate([Volume N],SAMEPERIODLASTYEAR(calendrier[Date]), calendrier[IsPast] = TRUE())

    If you use this measure instead of the other on the calculation you will get what is expected:

     

    The full explanation is on this blog post.

     

    https://www.sqlbi.com/articles/previous-year-up-to-a-certain-date/

     

    PBIX File attach.