Copied!
Copy to clipboard
let
Source = List.Dates(StartDate, #"Table Length", #duration(1, 0, 0, 0)),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table", {{"Column1", "Date"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns", {{"Date", type date}}),
StartDate = #date(2010, 1, 1),
EndDate = DateTime.Date(DateTime.LocalNow()),
#"Table Length" = Duration.Days(EndDate - StartDate)+1,
#"Creat Date Table" = #"Changed Type",
#"Inserted Year" = Table.AddColumn(#"Creat Date Table", "Year", each Date.Year([Date]), Int64.Type),
#"Inserted Month" = Table.AddColumn(#"Inserted Year", "MonthNo", each Date.Month([Date]), Int64.Type),
#"Inserted Month Name" = Table.AddColumn(#"Inserted Month", "MonthName", each Date.MonthName([Date]), type text),
#"Inserted YearMonth" = Table.AddColumn(#"Inserted Month Name", "YearMonth", each Number.ToText([Year]) & "/" & [MonthName], type text),
#"Inserted YearMonthNo" = Table.AddColumn(#"Inserted YearMonth", "YearMonthNo", each Number.ToText([Year]) & "/" & Number.ToText([MonthNo]), type text),
#"Inserted YearMonthSort" = Table.AddColumn(#"Inserted YearMonthNo", "YearMonthSort", each [Year]*1000 + [MonthNo], Int64.Type),
#"Inserted Quarter" = Table.AddColumn(#"Inserted YearMonthSort", "Quarter", each "Q" & Number.ToText(Date.QuarterOfYear([Date])), type text),
#"Inserted YearQuarter" = Table.AddColumn(#"Inserted Quarter", "YearQuarter", each Number.ToText([Year]) & "/" & [Quarter], type text),
#"Inserted Week" = Table.AddColumn(#"Inserted YearQuarter", "Week", each Date.WeekOfYear([Date]), Int64.Type),
#"Inserted YearWeek" = Table.AddColumn(#"Inserted Week", "YearWeek", each Number.ToText([Year]) & "/" & Number.ToText([Week]), type text),
#"Inserted YearWeekSort" = Table.AddColumn(#"Inserted YearWeek", "YearWeekSort", each [Year]*1000 + [Week], Int64.Type),
#"Inserted Day of Month" = Table.AddColumn(#"Inserted YearWeekSort", "Day", each Date.Day([Date]), Int64.Type),
#"Inserted Day of Week" = Table.AddColumn(#"Inserted Day of Month", "WeekDay", each Date.DayOfWeek([Date]), Int64.Type),
#"Inserted Day Name" = Table.AddColumn(#"Inserted Day of Week", "DayName", each Date.DayOfWeekName([Date]), type text)
in
#"Inserted Day Name"