Forum Discussion
How to properfly filter data for next week?
I have a full DimDate dimension with all columns, and I try to filter data for ‘next week’.
I have tried:
'Date'[Week Year Week Number] = CONVERT(CONCATENATE( YEAR(TODAY() ),WEEKNUM(TODAY(),21) ),INTEGER)+1
But of course I have 2 problems:
- when week is 52, I will just get 53.
- Also the column Week Year Week Number has values like 202202 And my WEEKNUM concat returns something like 20222 (they are different!)
How can I appropriately filter for ‘next week’ data?
Hi, Anonymous
Try to create a column like this:Week Year Week Number = var _Date=[Full Date] // change the Full Date to your Date var _Month=MONTH(_Date) var _yearOfTheDate=YEAR(_Date) var _NextWeekNum=Format(weeknum(_Date+7,21),"0#") var _int_WeekNum=CONVERT(_NextWeekNum,INTEGER) var _preYear=CONVERT((_yearOfTheDate-1)&_NextWeekNum,INTEGER) var _thisYear=CONVERT(_yearOfTheDate&_NextWeekNum,INTEGER) var _nextYear=CONVERT((_yearOfTheDate+1)&_NextWeekNum,INTEGER) var _if=IF(_Month<=1,IF(_int_WeekNum>50,_preYear,_thisYear),IF(_int_WeekNum>2,_thisYear,_nextYear)) return _ifResult:
Please refer to the attachment below for details.
Hope this helps.
Best Regards,
Community Support Team _ Zeon ZhengIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandak
Super User
Anonymous , use my blog using week for that. Next week +1 , last week -1
In a date or week table new column
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
ORWeek Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format
measures
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Next Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])+1))Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8 - v-angzheng-msft
Community Support
Hi, Anonymous
Try to create a column like this:Week Year Week Number = var _Date=[Full Date] // change the Full Date to your Date var _Month=MONTH(_Date) var _yearOfTheDate=YEAR(_Date) var _NextWeekNum=Format(weeknum(_Date+7,21),"0#") var _int_WeekNum=CONVERT(_NextWeekNum,INTEGER) var _preYear=CONVERT((_yearOfTheDate-1)&_NextWeekNum,INTEGER) var _thisYear=CONVERT(_yearOfTheDate&_NextWeekNum,INTEGER) var _nextYear=CONVERT((_yearOfTheDate+1)&_NextWeekNum,INTEGER) var _if=IF(_Month<=1,IF(_int_WeekNum>50,_preYear,_thisYear),IF(_int_WeekNum>2,_thisYear,_nextYear)) return _ifResult:
Please refer to the attachment below for details.
Hope this helps.
Best Regards,
Community Support Team _ Zeon ZhengIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.