So, we will need one small Excel Table and two blank Queries
Parameter ValueStartDate 29/07/2020EndDate 31/07/2020
in Name Manager change the name to Parameters
first Query
change the name to fnGetParameterCode:(ParameterName as text) => let ParamSource = Excel.CurrentWorkbook(){[Name="Parameters"]}[Content], ParamRow = Table.SelectRows(ParamSource, each ([Parameter]=ParameterName)), Value= if Table.IsEmpty(ParamRow)=true then null else Record.Field(ParamRow{0},"Value") in Value
second Query
change the name to CalendarCode:let startdate = Number.From(fnGetParameter("StartDate")), enddate = Number.From(fnGetParameter("EndDate")), Source = {startdate..enddate}, ToTable = Table.FromList(Source, Splitter.SplitByNothing(), type table[Date = Date.Type], null, ExtraValues.Error), Type = Table.TransformColumnTypes(ToTable,{{"Date", type date}}) in Type
this is a basic calendar with dates column only but it can be extended to months, days, years, weeks and so on
and extended result is
Date Year Month Month Name Quarter Week of Year Week of Month Day Day of Week Day of Year Day Name 29/07/2020 2020 7July 3 31 5 29 2 211Wednesday 30/07/2020 2020 7July 3 31 5 30 3 212Thursday 31/07/2020 2020 7July 3 31 5 31 4 213Friday






Bookmarks