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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
asdf1608
Helper V
Helper V

Need to create union in Power BI

I need ti union two tables from SQL Server in power BI. But the issue is that the number of columns are not same for both the tables. So union()/concadenate() is not possible in Power BI.

So I tried the append and connected to Database.

It is good but the values are wrong. 

 

So there any other ways to union these two tables in Power BI

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi, @asdf1608 

According to your description, you want to union the two tables which has differnt column names.

Here are the steps you can refer to :
This is my test data:

vyueyunzhmsft_0-1674182801939.png

vyueyunzhmsft_1-1674182809438.png

[1]We can crealize it in Power Query Editor. we can create a Blank Query and enter this:

= Table.RenameColumns(#"Table 2",{{"Stu_Name", "Name"}, {"Class_Name", "Class"}}) & #"Table 1"

Then we can get this and you can also remove the column you do not want to in it :

vyueyunzhmsft_2-1674182871241.png

 

[2]We can also realize it in Power Bi Desktop:
We can click "New Table" and enter this:

Table = UNION( SELECTCOLUMNS( ADDCOLUMNS('Table 2',"Teacher", BLANK()) ,"Name",[Stu_Name],"Class",[Class_Name],"Source",[Source],"Teacher",[Teacher]) , 'Table 1')

Then we can also meet your need:

vyueyunzhmsft_3-1674183051751.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi, @asdf1608 

According to your description, you want to union the two tables which has differnt column names.

Here are the steps you can refer to :
This is my test data:

vyueyunzhmsft_0-1674182801939.png

vyueyunzhmsft_1-1674182809438.png

[1]We can crealize it in Power Query Editor. we can create a Blank Query and enter this:

= Table.RenameColumns(#"Table 2",{{"Stu_Name", "Name"}, {"Class_Name", "Class"}}) & #"Table 1"

Then we can get this and you can also remove the column you do not want to in it :

vyueyunzhmsft_2-1674182871241.png

 

[2]We can also realize it in Power Bi Desktop:
We can click "New Table" and enter this:

Table = UNION( SELECTCOLUMNS( ADDCOLUMNS('Table 2',"Teacher", BLANK()) ,"Name",[Stu_Name],"Class",[Class_Name],"Source",[Source],"Teacher",[Teacher]) , 'Table 1')

Then we can also meet your need:

vyueyunzhmsft_3-1674183051751.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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