//Metadata: //Programming language: Power Query M //Natural language: English //Output: date table //Source: oriented on https://gorilla.bi/power-query/create-iso-week-and-iso-year/ //Explanation: //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: //Copy the code into an empty query or use as part of a larger date table let Today = Date.From(DateTime.LocalNow()), StartDate = #date(2022, 1, 1), EndDate = #date(2024, 1, 1), #"List of Dates" = List.Dates( StartDate, Duration.Days(EndDate - StartDate) + 1, #duration(1, 0, 0, 0) ), #"Converted to Table" = Table.FromList( #"List of Dates", Splitter.SplitByNothing(), type table [Date = Date.Type] ), #"ADD ISO 8601 Week" = Table.AddColumn( #"Converted to Table", "ISO Week", each let CurrentThursday = Date.AddDays([Date], 3 - Date.DayOfWeek([Date], Day.Monday)), YearCurrThursday = Date.Year(CurrentThursday), FirstThursdayOfYear = Date.AddDays( #date(YearCurrThursday, 1, 7), - Date.DayOfWeek(#date(YearCurrThursday, 1, 1), Day.Friday) ), ISO_Week = Duration.Days(CurrentThursday - FirstThursdayOfYear) / 7 + 1 in ISO_Week, Int64.Type ), #"ADD Current ISO 8601 Week" = Table.AddColumn( #"ADD ISO 8601 Week", "Current ISO Week", each #"ADD ISO 8601 Week"{[Date = Date.From(DateTime.LocalNow())]}[ISO Week], Int64.Type ) in #"ADD Current ISO 8601 Week"