Forum Discussion
Anonymous
5 years agoNot applicable
M code for dynamic week in Power Query
Dear all, I'm facing issue with M code for dynamic week in Power Query, appreciate your advice. I create a M code to define week# based on the current date as below. There is not issue to define th...
- 5 years ago
Here is modified version that should do that
= let date1 = Date.AddWeeks(Date.From(DateTime.LocalNow()), -25) in Number.ToText(Date.Year(date1)) & Text.PadStart(Number.ToText(Date.WeekOfYear(date1)),2,"0")
Pat
Anonymous
5 years agoNot applicable
Hi mahoneypat ,
Thanks for your advice!
I still have an issue with the number of week.
Could you please advsie how can I adjust to return the value is "202101" instead of "20211" for week 1 to week 9?
mahoneypat
Microsoft Employee
5 years agoHere is modified version that should do that
= let date1 = Date.AddWeeks(Date.From(DateTime.LocalNow()), -25) in Number.ToText(Date.Year(date1)) & Text.PadStart(Number.ToText(Date.WeekOfYear(date1)),2,"0")
Pat
- Anonymous5 years agoNot applicable
Thanks for your support!