Forum Discussion
Same Week last Year Flag
Hi Anonymous ,
try using SAMEPERIODLASTYEAR & WEEKNUM()
Logic steps:
1- create a column that would return your current year's week number (using WEEKNUM())
eg-WeekNum =WEEKNUM([Date])
2- Create a column called WeekYear = [WeekNum] * 10000 + [Year]
eg- 12022, 22022,32022... for 1st week of 2022, 2nd week of 2022, 3rd week of 2022 and so on respectively.
3- Create another column Week_Last_Year = [WeekYear] -1
eg- (if WeekYear is 22022 then Week_Last_year will be 22021)
4- Create a measure called TOTALSALES=sum(totalsales)
5- Create a measure for current week
Current_week = WEEKNUM(TODAY()) * 10000 + YEAR(TODAY())
6-Create measure for current week's sales
Current_Week_Sales= Calculate ([TotalSales],Filter(ALL(Calendartable), [WeekYear] = [Current_week ] ))
7. Create a measure called LastYear_SameWeekSales = Calculate ([TotalSales],Filter(ALL(Calendartable), [WeekLastYear] = [Current_Week] - 1))
Using this, you can compare your Sales at the same time this year and last year.
Please mark it as a solution if this helps you. Thanks.
Regards,
TruptiS
Hello and thanks for your reply!
To clarify, I am not looking for total sales. I am looking to see which products (by name) were being sold in the same week last year.
For example, if I know I sold Product A, B, and C this year this week, but I only sold Products A and B last year on the same week, I'd want to flag that product C was not being sold last year same week.