(StartDate as date, EndDate as date, optional Culture as nullable text) as table => let // Calculate the total number of days between the start and end dates DayCount = Duration.Days(Duration.From(EndDate - StartDate)) + 1, // Create a list of dates from StartDate to EndDate Source = List.Dates(StartDate, DayCount, #duration(1, 0, 0, 0)), // Convert the list of dates to a table TableFromList = Table.FromList(Source, Splitter.SplitByNothing()), // Change the column type of the generated table to date ChangedType = Table.TransformColumnTypes(TableFromList, {{"Column1", type date}}), // Rename the default column to 'Date' RenamedColumns = Table.RenameColumns(ChangedType, {{"Column1", "Date"}}), // Add a 'Year' column extracted from the 'Date' column InsertYear = Table.AddColumn(RenamedColumns, "Year", each Date.Year([Date]), type text), // Add a 'Quarter Num' column representing the quarter number of the year InsertQuarterNum = Table.AddColumn(InsertYear, "Quarter Num", each Date.QuarterOfYear([Date])), // Concatenate 'Q' with the quarter number to form a 'Quarter' column InsertQuarter = Table.AddColumn( InsertQuarterNum, "Quarter", each "Q" & Number.ToText([Quarter Num]) ), // Add a 'Month Num' column representing the month number of the year InsertMonth = Table.AddColumn( InsertQuarter, "Month Num", each Date.Month([Date]), type text ), // Add a 'StartOfMonth' column representing the first date of the month InsertStartOfMonth = Table.AddColumn( InsertMonth, "StartOfMonth", each Date.StartOfMonth([Date]), type date ), // Add an 'EndOfMonth' column representing the last date of the month InsertEndOfMonth = Table.AddColumn( InsertStartOfMonth, "EndOfMonth", each Date.EndOfMonth([Date]), type date ), // Add a 'DayOfMonth' column representing the day number of the month InsertDay = Table.AddColumn( InsertEndOfMonth, "DayOfMonth", each Date.Day([Date]) ), // Create a 'DateInt' column as an integer representation of the date InsertDayInt = Table.AddColumn( InsertDay, "DateInt", each [Year] * 10000 + [Month Num] * 100 + [DayOfMonth] ), // Add a 'Month' column with the full month name, based on the specified culture InsertMonthName = Table.AddColumn( InsertDayInt, "Month", each Date.ToText([Date], "MMMM", Culture), type text ), // Add a 'Month short' column with the abbreviated month name InsertShortMonthName = Table.AddColumn( InsertMonthName, "Month short", each Date.ToText([Date], "MMM", Culture), type text ), // Combine the short month name and year to form a 'Month Year' column InsertCalendarMonth = Table.AddColumn( InsertShortMonthName, "Month Year", each [Month short] & " " & Number.ToText([Year]), type text ), // Combine the quarter and year to form a 'Quarter Year' column InsertCalendarQtr = Table.AddColumn( InsertCalendarMonth, "Quarter Year", each "Q" & Number.ToText([Quarter Num]) & " " & Number.ToText([Year]), type text ), // Add a 'Weekday Num' column representing the day of the week InsertDayWeek = Table.AddColumn( InsertCalendarQtr, "Weekday Num", each Date.DayOfWeek([Date]) ), // Add a 'Weekday' column with the full name of the day of the week InsertDayName = Table.AddColumn( InsertDayWeek, "Weekday", each Date.ToText([Date], "dddd", Culture), type text ), // Add a 'Weekday short' column with the abbreviated day name InsertShortDayName = Table.AddColumn( InsertDayName, "Weekday short", each Date.ToText([Date], "ddd", Culture), type text ), // Add an 'StartOfWeek' column representing the last date of the week InsertWeekStarting = Table.AddColumn( InsertShortDayName, "StartOfWeek", each Date.StartOfWeek([Date]), type date ), // Add an 'EndOfWeek' column representing the last date of the week InsertWeekEnding = Table.AddColumn( InsertWeekStarting, "EndOfWeek", each Date.EndOfWeek([Date]), type date ), // Add a 'Week Num' column representing the week number of the year InsertWeekNumber = Table.AddColumn( InsertWeekEnding, "Week Num", each Date.WeekOfYear([Date]) ), // Add a 'WeekOfMonth Num' column representing the week number of the month InsertMonthWeekNumber = Table.AddColumn( InsertWeekNumber, "WeekOfMonth Num", each Date.WeekOfMonth([Date]) ), // Combine the weeknum and year to form a 'Week Year' column InsertCalendarWeek = Table.AddColumn( InsertMonthWeekNumber, "Week Year", each "W" & Number.ToText([Week Num]) & " " & Number.ToText([Year]), type text ), // Create a 'Week-YearOrder' column for sorting purposes InsertWeeknYear = Table.AddColumn( InsertCalendarWeek, "Week-YearOrder", each [Year] * 10000 + [Week Num] * 100 ), // Create a 'Month-YearOrder' column for sorting purposes InsertMonthnYear = Table.AddColumn( InsertWeeknYear, "Month-YearOrder", each [Year] * 10000 + [Month Num] * 100 ), // Create a 'Quarter-YearOrder' column for sorting purposes InsertQuarternYear = Table.AddColumn( InsertMonthnYear, "Quarter-YearOrder", each [Year] * 10000 + [Quarter Num] * 100 ), //Add a 'Current Date' column in case we need it for our analysis Added_Current_Date_column = Table.AddColumn( InsertQuarternYear, "Current Date", each Date.From(DateTime.LocalNow()) ), // Change the column types of various columns to integer and text types ChangedType1 = Table.TransformColumnTypes( Added_Current_Date_column, { {"Quarter-YearOrder", Int64.Type}, {"Week Num", Int64.Type}, {"WeekOfMonth Num", Int64.Type}, {"Quarter", type text}, {"Year", Int64.Type}, {"Month-YearOrder", Int64.Type}, {"Week-YearOrder", Int64.Type}, {"DateInt", Int64.Type}, {"DayOfMonth", Int64.Type}, {"Month Num", Int64.Type}, {"Quarter Num", Int64.Type}, {"Weekday Num", Int64.Type}, {"Current Date", type date} } ) in ChangedType1