Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Week inclusion in SamePeriodLastyear

Hi all,

 

I have an issue with the 'Sameperiodlastyear' DAX formular. my initial data table looks something like this:

 

DateStart of the weekYearweeksales
19.05.201914.05.20192019201
20.05.201920.05.20192019212
...............

 

It has all the week from 01.01.2018 (week one of 2018)  to 17.05.2020 (week 2020)

 

Furthermore, from the same table I retriev the total sum of sales. Now I would like to create a table that looks like this:

 

YearTotal SalesSamePeriodlastyear
2018500 
20191000500
20202001000

 

But what I receive is this:

 

YearTotal SalesSamePeriodlastyear
2018500500
20191000300
2020200 

 

The 300 and 500 are the issues here. For 2020 my data inlcudes sales including week 20. So I would expect the same period last year function to also show just the first 20 weeks. But for some reason it includes 22 weeks.

 

My Formulars are Total= SUMX(Category,Category[Value])and CALCULATE( [total]; SAMEPERIODLASTYEAR(Date;Date[StartofWeek])

 

Ho das powerbi figures out the

what could be the issue tah powerbi includes 22 weeks for 2019 rather than 20 and ho can i display the number for 2019 in 2020 ,..

 

greeting

 

 

 

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Greg_Deckler Thanks for the tip. I will try it later on.

     

    I found another way that works as well.

     

    weeklysales = calculate([ValueTotalCategory];Filter(ALL('Date');'Date'[CalendarYear]=SELECTEDVALUE('Date'[CalendarYear])-1 && 'Date'[Week]=SELECTEDVALUE('Date'[Week])))

2 Replies