-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLoadSupportData.pq
More file actions
31 lines (26 loc) · 877 Bytes
/
LoadSupportData.pq
File metadata and controls
31 lines (26 loc) · 877 Bytes
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
(
optional FilePath as text) as record =>
let
FilePath = if FilePath = null then P[Support File] else FilePath,
Source = Excel.Workbook(
Binary.Buffer(
File.Contents(FilePath)),
null, true),
#"Filtered Table" = Table.SelectRows(Source, each ([Kind] = "Table" and [Name] <> "tblSupportData")),
Selector =
(TableName as text) =>
try Table.SelectRows(
Source{[Name="tblSupportData"]}[Data], each [Name] = TableName)
otherwise
Table.FromColumns({
Table.ColumnNames(Source{[Name=TableName]}[Data]),
Table.ColumnNames(Source{[Name=TableName]}[Data])},
{"Column Name", "Output Column Name"}),
#"Choose and Rename" = Table.Buffer(Table.AddColumn(
#"Filtered Table", "Value",
each F[RenameColumnsByMapping](
[Data], Selector([Name]), "Column Name"))),
#"To Record" =
Record.FromTable(#"Choose and Rename")
in
#"To Record"