Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Same Period Next Year

Hey all,

 

I am looking for the following:

 

ID    Products  YearMonth                                              

2         1             202002

4         1             202004

5         2             202004

9         5             202004

2        3              202102

4         4            202104

5          6            202009

 

ID    Products  YearMonth     ProductsNY                                         

2         1             202001             3

4         1             202004             4

5         2             202004             6

9         5             202004            (next years results)

2        3              202003          (next years results)

4          5            202005            (next years results)

5          6            202009             (next years results)

 

I've tried DATEADD / ParallelPeriod, but haven't been able to get it to work. I'm trying to get the "Products" column amount from the next year(month), in a new column.

 

How would I get this to work?

 

Would love to hear it!

Thanks :),

Daniël

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    You could use EARLIER() function.

    ProductsNY = CALCULATE(SUM('Table'[Products]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[YearMonth]=EARLIER('Table'[YearMonth])+100))

     

    Best Regards,

    Jay

3 Replies

  • Anonymous , if you have date  , then with help from a date table

     

    new measure

     

    Year behind Sales = CALCULATE(SUM(Table[Products]),dateadd('Date'[Date],-1,Year))

     

    else move year period/month in a new table and join back, also have column year and period /month

     

    next year = CALCULATE(sum('Table'[products]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])+1 && 'Date'[Month] = Max('Date'[Month])))

    • ypannnn's avatar
      ypannnn
      Frequent Visitor

      dateadd('Date'[Date],-1,Year) really helps my question! Thank you!! 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    You could use EARLIER() function.

    ProductsNY = CALCULATE(SUM('Table'[Products]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[YearMonth]=EARLIER('Table'[YearMonth])+100))

     

    Best Regards,

    Jay