Forum Discussion
Create Calendar Table with row per minute
- 9 years ago
It can be done in the query editor, e.g. for 2017
Table.FromColumns({List.DateTimes(#datetime(2017,1,1,0,0,0),365*1440,#duration(0,0,1,0))}, type table[DateTime=datetime]) - 9 years ago
There was another post questioning if this could be done for the last 6 months or so. This post was removed, while I was preparing my answer.
This query will produce the table starting on the first, 6 months ago (so currently Decmber 1, 2016) and ends on the last day of the current mont (curently June 2017), 11:59 PM:
let Start = Date.AddMonths(Date.StartOfMonth(DateTime.LocalNow()),-6), End = Date.AddMonths(Start,7), Count = Number.From(End-Start)*1440, Calendar = Table.FromColumns({List.DateTimes(Start,Count,#duration(0,0,1,0))}, type table[DateTime=datetime]) in Calendar
There was another post questioning if this could be done for the last 6 months or so. This post was removed, while I was preparing my answer.
This query will produce the table starting on the first, 6 months ago (so currently Decmber 1, 2016) and ends on the last day of the current mont (curently June 2017), 11:59 PM:
let
Start = Date.AddMonths(Date.StartOfMonth(DateTime.LocalNow()),-6),
End = Date.AddMonths(Start,7),
Count = Number.From(End-Start)*1440,
Calendar = Table.FromColumns({List.DateTimes(Start,Count,#duration(0,0,1,0))}, type table[DateTime=datetime])
in
Calendar
Yes, I removed the question, because I thought I had the solution already with the following Query:
= Table.FromColumns({List.DateTimes(Date.AddDays(DateTime.LocalNow(),-180),180*1440,#duration(0,0,1,0))}, type table[DateTime=datetime])But then I realised that this calendar produced duplicate Rows on March 26, when the time shift occurred.
And strange thing, I could not remove the duplicate Rows with the Built in function!
But luckily, you came around with your solution and this one does not have duplicate rows :)
Thank you so much, again!