Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
marbi
Helper I
Helper I

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 FIELDA KEY FIELDA
KEY FIELDB KEY FIELDB
COLUMNC COLUMNG
COLUMND COLUMNH
COLUMNE COLUMNI
COLUMNF COLUMNJ
2 ACCEPTED SOLUTIONS
Akash_Varuna
Super User
Super User

Hi @marbi  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.

View solution in original post

PijushRoy
Super User
Super User

Hi @marbi 
Can you please try similar SQL Code for your solution in Direct Query mode
Write this SQL in SQL Query box

SELECT
    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;

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





View solution in original post

6 REPLIES 6
v-mdharahman
Community Support
Community Support

Hi @marbi,

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 Team

 

If this post helps then please mark it as a solution, so that other members find it more quickly.

Thank you.

Hi @marbi,

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.

Hi @marbi,

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.

Hi @marbi,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

 

Thank you.

PijushRoy
Super User
Super User

Hi @marbi 
Can you please try similar SQL Code for your solution in Direct Query mode
Write this SQL in SQL Query box

SELECT
    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;

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Akash_Varuna
Super User
Super User

Hi @marbi  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.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.