//Metadata: //Programming language: Power Query M //Natural language: English //Output: date function //Explanation: //CalendarWeek is set to American by default. ISO8601Week can only be generated //Generates date table used in large parts of the world, except US //see also: https://en.wikipedia.org/wiki/ISO_week_date //How to use: //This function expects a valid date as argument and can be invoked as a function = (DateColumn as date) => let CurrentThursday = Date.AddDays(DateColumn, 3 - Date.DayOfWeek(DateColumn, Day.Monday)), YearCurrentThursday = Date.Year(CurrentThursday), FirstThursdayOfYear = Date.AddDays( #date(YearCurrentThursday, 1, 7), - Date.DayOfWeek(#date(YearCurrentThursday, 1, 1), Day.Friday) ), ISO8601Week = Duration.Days(CurrentThursday - FirstThursdayOfYear) / 7 + 1 in ISO8601Week