forked from alisonpezzott/cotacoes-bcb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfCotacoes.pq
More file actions
58 lines (52 loc) · 1.5 KB
/
Copy pathfCotacoes.pq
File metadata and controls
58 lines (52 loc) · 1.5 KB
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
58
let
moedas = Table.Buffer(Table.SelectRows(dMoedas[[Moeda]], each [Moeda] <> "BRL")),
addDatas = Table.AddColumn(
moedas,
"Datas",
each Table.FromList(
List.Dates(
dataInicial,
Duration.Days(dataFinal-dataInicial)+1,
#duration(1, 0, 0, 0)
),
Splitter.SplitByNothing(),
type table [ Data = date ]
),
type table [ Data = date ]
),
addCotacoes = Table.AddColumn(
addDatas,
"Cotacoes",
each getCotacoesPaginacao(
dataInicial,
dataFinal,
[Moeda]
),
type table [ DataCotacao = date, Cotacao = Currency.Type ]
),
addJoin = Table.AddColumn(
addCotacoes,
"Join", each Table.Join(
[Datas], "Data",
[Cotacoes], "DataCotacao",
JoinKind.LeftOuter
),
type table [ Data = date, DataCotacao = date, Cotacao = Currency.Type ]
),
colunasSelecionadas = addJoin[[Moeda],[Join]],
tratamentoColunas = Table.TransformColumns(
colunasSelecionadas, {
{
"Join",
each Table.FillDown(Table.Sort(_[[Data],[Cotacao]], {"Data", Order.Ascending}), {"Cotacao"}),
type table [Data=date, Cotacao = Currency.Type]
}
}
),
expJoin = Table.ExpandTableColumn(
tratamentoColunas,
"Join",
{"Data", "Cotacao"}
)
in
expJoin