martingaleh
Board Regular
- Joined
- Jul 18, 2011
- Messages
- 83
There are a number of youtube videos where you can append the data of many workbooks together if they're in tables or the column names are the same or the column positions are the same etc. Here are the challenges I've faced:
1. the Worksheets are all different names, however there is only one worksheet in the workbook --solved
2. the data is in a worksheet, not a table
3. there are any number of columns.
My solution so far includes using this Transform Process From Binary function, which I amended:
Then in the aggregating sheet I have this:
There are a couple of issues here. the Transform Process From Binary function is supposed to promote headers from all of the sheets, but it doesn't, it only promotes headers from the first sheet and keeps "Column1" etc as the names of all the other sheets if they don't coincide with a name that already exists on the sample sheet.
Then when we use Table.ExpandTableColumn the the aggregating sheet:
Table.ColumnNames(#"Transform File from process"(#"Sample File")) I only get the names of the column in that sample file. If other downstream files don't have these column names and instead has different columns with different names, I'll lose those columns.
What I want is:
1. the Worksheets are all different names, however there is only one worksheet in the workbook --solved
2. the data is in a worksheet, not a table
3. there are any number of columns.
My solution so far includes using this Transform Process From Binary function, which I amended:
Power Query:
= (#"Sample File Parameter1" as binary) => let
Source = Excel.Workbook(#"Sample File Parameter1", null, true),
Sheet1_Sheet = Source{[Item=Source{0}[Item],Kind="Sheet"]}[Data], <--select first sheet
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true])
in
#"Promoted Headers"
Power Query:
let
Source = Folder.Files("C:\Users\kobe.bryant\Downloads\June\process"),
#"Added Custom" = Table.AddColumn(Source, "Tables", each Excel.Workbook([Content])),
#"Filtered Hidden Files1" = Table.SelectRows(#"Added Custom", each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File from process", each #"Transform File from process"([Content])),
#"Removed Other Columns1" = Table.SelectColumns(#"Invoke Custom Function1", {"Transform File from process"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File from process", Table.ColumnNames(#"Transform File from process"(#"Sample File")))
in
#"Expanded Table Column1"
There are a couple of issues here. the Transform Process From Binary function is supposed to promote headers from all of the sheets, but it doesn't, it only promotes headers from the first sheet and keeps "Column1" etc as the names of all the other sheets if they don't coincide with a name that already exists on the sample sheet.
Then when we use Table.ExpandTableColumn the the aggregating sheet:
Table.ColumnNames(#"Transform File from process"(#"Sample File")) I only get the names of the column in that sample file. If other downstream files don't have these column names and instead has different columns with different names, I'll lose those columns.
What I want is: