Microsoft Power Query创build表

我从网上复制了下面的代码来自动创build一个date表以供进一步的使用。 我也需要表中的季度,所以我添加了一行代码:

Quarter = Table.AddColumn(Year, "QuarterOfYear", each Date.QuarterOfYear([Date])), 

表格创build的很好,但没有“QuarterOfYear”列。 我确定我错过了一些东西。

任何有用的提示? 谢谢。

完整的脚本:

  let CreateDateTable = (StartDate, EndDate) => let //StartDate=#date(2010,1,1), //EndDate=#date(2014,12,31), //Create lists of month and day names for use later on MonthList = {"January", "February", "March", "April", "May", "June" , "July", "August", "September", "October", "November", "December"}, DayList = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}, //Find the number of days between the end date and the start date NumberOfDates = Duration.Days(EndDate-StartDate), //Generate a continuous list of dates from the start date to the end date DateList = List.Dates(StartDate, NumberOfDates, #duration(1, 0, 0, 0)), //Turn this list into a table TableFromList = Table.FromList(DateList, Splitter.SplitByNothing(), {"Date"} , null, ExtraValues.Error), //Caste the single column in the table to type date ChangedType = Table.TransformColumnTypes(TableFromList,{{"Date", type date}}), //Add custom columns for day of month, month number, year DayOfMonth = Table.AddColumn(ChangedType, "DayOfMonth", each Date.Day([Date])), MonthNumber = Table.AddColumn(DayOfMonth, "MonthNumberOfYear", each Date.Month([Date])), Year = Table.AddColumn(MonthNumber, "Year", each Date.Year([Date])), Quarter = Table.AddColumn(Year, "QuarterOfYear", each Date.QuarterOfYear([Date])), DayOfWeekNumber = Table.AddColumn(Year, "DayOfWeekNumber", each Date.DayOfWeek([Date])+1), //Since Power Query doesn't have functions to return day or month names, //use the lists created earlier for this MonthName = Table.AddColumn(DayOfWeekNumber, "MonthName", each MonthList{[MonthNumberOfYear]-1}), DayName = Table.AddColumn(MonthName, "DayName", each DayList{[DayOfWeekNumber]-1}), IsThisWeek = Table.AddColumn(DayName, "IsThisWeek", each Date.IsInCurrentWeek([Date])), //Add a column that returns true if the date on rows is the current date IsToday = Table.AddColumn(IsThisWeek, "IsToday", each Date.IsInCurrentDay([Date])), IsThisYear = Table.AddColumn(IsToday, "IsThisYear", each Date.IsInCurrentYear([Date])), WeekEnding = Table.AddColumn(IsThisYear , "Week Ending", each Date.EndOfWeek([Date])), #"Removed Columns" = Table.RemoveColumns(WeekEnding,{"IsToday"}), #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"DayOfMonth", Int64.Type}, {"MonthNumberOfYear", Int64.Type}, {"Year", Int64.Type}, {"DayOfWeekNumber", Int64.Type}}) in #"Changed Type", #"Aufgerufene FunktionCreateDateTable" = CreateDateTable(#date(2013, 1, 1), #date(2017, 12, 31)) in #"Aufgerufene FunktionCreateDateTable" 

您需要编辑插入的下一行:DayOfWeek。 它需要引用插入的步骤名称,例如

DayOfWeekNumber = Table.AddColumn(Quarter, "DayOfWeekNumber", each Date.DayOfWeek([Date])+1),