Forum Discussion
Merge tables using Direct Query
I want to combine two tables with different number of columns.
Both tables has same common fields as A & B and would like to combine that will result to a table having fields: A, B, C, D, E, F, G, H, I, J. Kindly help.
| TABLE 1 | TABLE 2 | |||
| COLUMN | COLUMN | |||
| KEY FIELD | A | KEY FIELD | A | |
| KEY FIELD | B | KEY FIELD | B | |
| COLUMN | C | COLUMN | G | |
| COLUMN | D | COLUMN | H | |
| COLUMN | E | COLUMN | I | |
| COLUMN | F | COLUMN | J |
Hi Anonymous Create a UNION SQL query combining the tables, ensuring missing columns are filled with NULL and matching fields like A and B align. Use Advanced Query Editor in Power BI to input the query in DirectQuery mode. Verify data types of common fields (A and B) match in both tables for proper merging.
Hi Anonymous
Can you please try similar SQL Code for your solution in Direct Query mode
Write this SQL in SQL Query boxSELECT T1.KEY FIELDA, T1.KEY FIELDB, T1.COLUMN C, T1.COLUMN D, T1.COLUMN E, T1.COLUMN F, T2.COLUMN G, T2.COLUMN H, T2.COLUMN I, T2.COLUMN J FROM TABLE1 T1 FULL OUTER JOIN TABLE2 T2 ON T1.KEY FIELDA = T2.KEY FIELDA AND T1.KEY FIELDB = T2.KEY FIELDB;
6 Replies
- Akash_Varuna
Super User
Hi Anonymous Create a UNION SQL query combining the tables, ensuring missing columns are filled with NULL and matching fields like A and B align. Use Advanced Query Editor in Power BI to input the query in DirectQuery mode. Verify data types of common fields (A and B) match in both tables for proper merging.
- PijushRoy
Community Champion
Hi Anonymous
Can you please try similar SQL Code for your solution in Direct Query mode
Write this SQL in SQL Query boxSELECT T1.KEY FIELDA, T1.KEY FIELDB, T1.COLUMN C, T1.COLUMN D, T1.COLUMN E, T1.COLUMN F, T2.COLUMN G, T2.COLUMN H, T2.COLUMN I, T2.COLUMN J FROM TABLE1 T1 FULL OUTER JOIN TABLE2 T2 ON T1.KEY FIELDA = T2.KEY FIELDA AND T1.KEY FIELDB = T2.KEY FIELDB; - AnonymousNot applicable
Hi Anonymous,
Thanks for reaching out to the Microsoft fabric community forum.
It looks like you are trying to merge columns from two different tables. As PijushRoy and Akash_Varuna both responded to your query, kindly go through their responses and check if it solves your query.
I would also take a moment to thank PijushRoy and Akash_Varuna, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support TeamIf this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
- AnonymousNot applicable
Hi Anonymous,
As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.
If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.
If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
Thank you for your patience and look forward to hearing from you.- AnonymousNot applicable
Hi Anonymous,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.
Thank you.