-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathList.AllDates.pq
57 lines (48 loc) · 1.83 KB
/
List.AllDates.pq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
let
List.AllDates_Impl = (source as list) as table =>
/*
Generate all dates between 2 or more dates. (order does not matter)
rewrite/rename: 'List.ContinuousDates.pq'
Source: <https://github.com/ninmonkey/Ninmonkey.PowerQueryLib/blob/master/source/List.ContinuousDates.pq>
input:
a list or table table column of dates
output:
table of continuous [Date]s., for a Date table
future:
auto detect if arg is a table or a list
*/
let
// source = List.Buffer(source), // maybe?
// future: assert compat with dates,
validArgs = source is list and first is date and last is date,
first = List.Min(source) as date,
last = List.Max(source) as date,
days = { Number.From(first)..Number.From(last) },
extra = [ ValidArgs = validArgs, first = first, last = last, days = days ],
Datefrom = DateTime.Date()
in
extra,
// a
// let
// first = List.Min(source),
// last = List.Max(source),
// days = { Number.From(first)..Number.From(last) },
// baseDates = List.Transform(
// days, each Date.From(_) ),
// FinalTable = Table.FromList(
// baseDates, Splitter.SplitByNothing(),
// type table[Date = date], null, ExtraValues.Error
// )
// in
// FinalTable,
// show_example = false,
// example =
// let
// sample = { #date(2010,1,9), #date(2010,1,3), #date(2010,1,5) },
// result = List.AllDates_Impl(sample)
// in
// result,
// FinalResult =
// if show_example then example else List.AllDates_Impl
in
FinalResult