Jan 30 2024 02:10 AM
Hi, I have multiple excel files with 3 columns that I want to merge into one sheet. If possible, I would like to have one empty column between each 3 columns. I figured out I would use power query for the import. I got as far as having tables with data in power query, but I need to extract them side by side. First picture is what I have and the second is what I want.
Thank you for all the help!
Jan 30 2024 10:36 PM
In theory that's possible, however it's better to have simple sample file. The only, Power Query returns structured table. Since table can't have repeated headers, they will be like Load1, Load2, etc for each first column, for empty columns it could be Balnk1, Blank2, etc. or so. Could be variants, but in any case each header shall to have it's own unique name.
If you are on Excel 365 perhaps it's better to use formulae and HSTACK all table. Details depends on what are source tables, are they dynamic (number and names) or not.
Jan 30 2024 10:41 PM
I'd be happy to help you merge your multiple Excel files and extract the data into separate columns with Power Query. To achieve this, you'll need to employ a few steps:
1. Combine the files:
There are two ways to do this:
Using "Append" function:
Using "Table.Combine" function:
2. Extract data into separate columns:
3. Add empty columns:
#"YourCombinedTable" = Table.InsertColumn(#"YourCombinedTable", "Empty1", List.Repeat(null, Table.RowCount(#"YourCombinedTable")), Int64.From(4))
4. Rename columns:
Remember to replace "YourCombinedTable" with the actual name of your table and adjust the formulas based on your specific column positions and desired layout.
By following these steps, you should be able to merge your Excel files and extract the data into separate columns with empty columns in between, achieving the desired layout you shared in the pictures.
Jan 31 2024 06:20 AM
Back to Power Query, as variant.
If some step tables returns set of them like
steps could be
let
....
tables = ....,
headers = List.Combine(
List.Transform( tables[Tables],
(q) => List.Transform( Table.ColumnNames(q) & {"sp"},
(p) => p & Text.From( List.PositionOf(tables[Tables], q) ) ) ) ),
columns = List.Combine( List.Transform( tables[Tables], (q) => (Table.ToColumns(q) & {{}}) ) ),
result = Table.FromColumns( columns, headers )
in
result
which gives something like