Forum Discussion
Sales last year, same week number, same day
Hello there,
I am currently having current year sales and have a measure calculating last year sales. However, it is looking on the same day last year increments but I am more interested in looking in the same week number, same day number (so if it is week 42, Monday, to look last year in week 42, Monday).
I have managed to get the correct sales per day by creating a new collumn like this :
Thank you in advance.
2 Replies
- v-yadongf-msft
Community Support
Hi AlexandruP ,
Can you share with me some screenshots of your data after hiding sensitive information and tell me what's your expected output?
Thanks for your efforts & time in advance.
Best regards,
Yadong Fang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AlexandruPFrequent Visitor
Hi v-yadongf-msft ,
Thank you for the interest. So I have the current data, but I also want to calculate different KPI comparing a certain period with the corresponding period from last year.
Let's say I want a sales IDX, I want for the last year values to take the same week number and weekday number as in the period selected. From my posted above measures I can get correct values but only for pre-determined 1-week; 1-day increments. (those are the new measure I was trying to replicate what I want)
I want if I select in a visual 4 weeks all together to get the aggregate sales for last year for that time span.
Currently if I select let's say 3-30 Oct for the last year I will get sales from 3-30 Oct
BUT this year, this period is representing weeks 40-43 and last year it was not in exactly the same weeks so I do not get an accurate comparison. I want when looking for Last Year Sales to find the same week number and same week-day-number for no matter the time span I select.
Also, current measure to see past sales, that look on same day of last year (16 okt 2022- looks on 16 okt 2021 NOT WHAT I AM INTERSTED IN is written like this:
Oms. kr. SÅ =IF (COUNTROWS ( D_Periode ) > 1,VAR max_weekday =WEEKDAY ( MAX ( F_Butikssalg[Dato] ), 2 )VAR max_date =CALCULATE ( DATEADD ( D_Periode[Dato], -1, YEAR ), D_Periode[Dato] = MAX ( F_Butikssalg[Dato] ) )VAR min_date =CALCULATE ( DATEADD ( D_Periode[Dato], -1, YEAR ), D_Periode[Dato] = MIN ( F_Butikssalg[Dato] ) )RETURNSWITCH (SELECTEDVALUE ( D_Tidsforhold[Periode] ),"Nuværende uge",CALCULATE ([Oms. kr.],FILTER (ALL ( D_Periode ),D_Periode[ÅrUge]= MAX ( D_Periode[ÅrUge] ) - 100&& MAX ( D_Periode[UgedagIndex] ) >= D_Periode[UgedagIndex]&& MIN ( D_Periode[UgedagIndex] ) <= D_Periode[UgedagIndex]&& WEEKDAY ( D_Periode[Dato], 2 ) <= max_weekday)),CALCULATE ([Oms. kr.],FILTER (ALL ( D_Periode ),D_Periode[Dato] <= max_date&& D_Periode[Dato] >= min_date))),SWITCH (SELECTEDVALUE ( D_Tidsforhold[Periode] ),"Nuværende uge",CALCULATE ([Oms. kr.],FILTER (ALL ( D_Periode ),D_Periode[ÅrUge]= MAX ( D_Periode[ÅrUge] ) - 100&& MAX ( D_Periode[UgedagIndex] ) >= D_Periode[UgedagIndex]&& MIN ( D_Periode[UgedagIndex] ) <= D_Periode[UgedagIndex])),CALCULATE ( [Oms. kr.], SAMEPERIODLASTYEAR ( D_Periode[Dato] ))))Oms. kr. - sales of this year
Oms. kr. SÅ - sales of last year
Relations going from period to sales are based on date written like dd/mm/yyyy
To bottom line it: I want my time span (no matter the selection) for last year to be percieved as
week-day+week-number+last-year
AND NOT (as it currently is)
month-day+last-year