#PowerQuery – Calculate the ISO date from year and a week number
Just wanted to share a M function that I just created to calculate the date from a Year and a ISO week number.
The example data is the following
Now the function I created can be called with the Year and Week number as parameters to get the following result
The function has the following code and will return the date of the Monday of the week number.
(TheYear as number, TheWeek as number) as date =>
let
//test
//TheYear = 2018,
//TheWeek = 1,
//
offsetToISO = Date.AddDays(#date(TheYear,1,1),-4),
dayOfWeek = Date.DayOfWeek(offsetToISO),
offset = -dayOfWeek + (TheWeek * 7),
isoWeekDate = Date.AddDays(offsetToISO, offset)
in
isoWeekDate
Hope this can help you too.
Here is a link to an example pbix file – link