Forum Discussion
Append two tables with different sizes
I have table one with 5 columns and table two with 7 columns.
How can I append them into a new table with only the common columns (that is, the columns with common names)?
I tried all sorts of "Append Queries" in the Query Editor but it seems that it only works with exactly identical tables.
In DAX, UNION seems to have the same limitation.
Thanks, I've figured out how appending works on Power BI desktop.
In fact, it is quite simple.
Thank you
8 Replies
- CahabaDataMemorable Member
One approach: use the New Table feature and only include the columns wanted. Call this Table V2. Maybe you have to do that for both - not sure. Then append one to the other.
- SeanCommunity Champion
I would do this in the Query Editor with Merge Queries
As to which type of Merge to use look here...
http://www.excelguru.ca/blog/2015/12/16/merge-tables-using-outer-joins-in-power-query/
and
http://www.excelguru.ca/blog/2015/12/23/merge-tables-using-inner-and-anti-joins-in-power-query/
Hope this helps! :smileyhappy:
- webportalImpactful Individual
Thanks, but I think I need to append and not merge. It seems the solution would be to harmonize the column names for both tables in the editor and then all columns will show in the appended table.
Then, I'll remove the ones I don't need.
Thanks anyway.
- v-sihou-msftMicrosoft Employee
In Power BI Desktop, when using "Append Queries", if two tables have different number of columns, it will append all columns together and generate columns of blank values for the table with less columns. It's "CROSS" appending. If you want to do "INNER" appending. You have to copy Table2 and only keep 5 columns, then append with Table1.
Regards,