Append Queries with different Colulmn Names

asjones987

New member
Joined
Feb 7, 2020
Messages
14
Reaction score
0
Points
0
Excel Version(s)
2019
I have 2 queries with very different headers and many columns each. However I have rearranged things so the data is the same.

Is there a simple way to append the two queries? When i tried with the current data set it would put the tables "next" to each other with NULL in the extra spots.

I wanted to "demote" the headers in each table and force the generic COLUMN1, COLUMN2,..... COLUMN36, then try the merge but can't find a good way to demote headers and let the auto headers get generated.

Any thoughts?

Thanks

Alan
 
Use the List.Zip trick to rename all columns in Table2 from Table1, then append

Code:
let

    FirstTable = Table1,
    OtherTable = Table.RenameColumns(Table2,List.Zip({Table.ColumnNames(Table2),Table.ColumnNames(Table1)})),
    Combined= Table.Combine({FirstTable, OtherTable})
in
Combined
 
Or, if you want to avoid custom code...

Providing the columns are all in the same order, the "Use First Row as Headers" button is a split button and the other option is "Use Headers as First Row", which does demote the headers into the data. If you were to do that on both tables, you could then append them. (You may want to remove the top 1 row from one of the queries after doing it so that you don't end up with the second table's header in the middle of your data.)
 
Back
Top