-
Notifications
You must be signed in to change notification settings - Fork 30
/
PreppinData_2021W1.pq
123 lines (123 loc) · 3.23 KB
/
PreppinData_2021W1.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
let
Source =
Csv.Document(
File.Contents("C:\Users\blah_blah_blah\Downloads\PD 2021 Wk 1 Input - Bike Sales.csv"),
[
Delimiter = ",",
// Columns = 6, BAD! BAD - OPTIONAL ARGUMENT! DO NOT WANT!
Encoding = 1252,
QuoteStyle = QuoteStyle.None
]
),
#"Promoted Headers" =
Table.PromoteHeaders(
Source,
[PromoteAllScalars = true]
),
#"Removed Top 10 Rows" = Table.Skip(#"Promoted Headers", 10),
#"Split Column by Delimiter" =
Table.SplitColumn(
#"Removed Top 10 Rows",
"Store - Bike",
Splitter.SplitTextByDelimiter(
" - ",
QuoteStyle.Csv
),
{
"Store",
"Bike"
}
),
#"Transform Columns" =
Table.TransformColumns(
#"Split Column by Delimiter",
{
{
"Bike",
each
if Text.StartsWith(Text.Upper(_), "R") then
"Road"
else if Text.StartsWith(Text.Upper(_), "M") then
"Mountain"
else
"Gravel"
},
{
"Date",
each Date.From(_, "en-GB")
}
}
),
#"Inserted Quarter" =
Table.AddColumn(
#"Transform Columns",
"Quarter",
each Date.QuarterOfYear([Date]),
Int64.Type
),
#"Inserted Day" =
Table.AddColumn(
#"Inserted Quarter",
"Day of Month",
each Date.Day([Date]),
Int64.Type
),
#"Removed Columns" =
Table.RemoveColumns(
#"Inserted Day",
{"Date"}
),
#"Reordered Columns" =
Table.ReorderColumns(
#"Removed Columns",
{
"Quarter",
"Store",
"Bike",
"Order ID",
"Customer Age",
"Bike Value",
"Existing Customer?",
"Day of Month"
}
),
#"Changed Type" =
Table.TransformColumnTypes(
#"Reordered Columns",
{
{
"Order ID",
Int64.Type
},
{
"Customer Age",
Int64.Type
},
{
"Bike Value",
Int64.Type
},
{
"Existing Customer?",
type text
},
{
"Store",
type text
},
{
"Bike",
type text
},
{
"Quarter",
Int64.Type
},
{
"Day of Month",
Int64.Type
}
}
)
in
#"Changed Type"