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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
River
Helper IV
Helper IV

create a union table with new column names

Hi Friend,

 

I need to create a union table from two different tables, with different column name. Let's say union SalesOrder and PurchOrder number into new table's new column called SOPO.

 

How can I do it?

 

Many thanks!

1 ACCEPTED SOLUTION
edhans
Super User
Super User

You need to rename the column in the 2nd table @River . You can do it before Append operation, or during the append operation. For example, here is Table1 and Table2

edhans_0-1614301515683.png

edhans_1-1614301548490.png

THis code does a Union into the new SPMO column

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [SalesOrder = _t]),
    #"Appended Query" = 
        Table.Combine(
            {
                Table.RenameColumns(Source, {{"SalesOrder", "SPMO"}}),
                Table.RenameColumns(Table2, {{"PurchaseOrder","SPMO"}})
            }
        )
in
    #"Appended Query"

edhans_2-1614301598122.png

How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.

 

Here is my PBIX file to help you see it work.

 

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

5 REPLIES 5
edhans
Super User
Super User

You need to rename the column in the 2nd table @River . You can do it before Append operation, or during the append operation. For example, here is Table1 and Table2

edhans_0-1614301515683.png

edhans_1-1614301548490.png

THis code does a Union into the new SPMO column

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [SalesOrder = _t]),
    #"Appended Query" = 
        Table.Combine(
            {
                Table.RenameColumns(Source, {{"SalesOrder", "SPMO"}}),
                Table.RenameColumns(Table2, {{"PurchaseOrder","SPMO"}})
            }
        )
in
    #"Appended Query"

edhans_2-1614301598122.png

How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.

 

Here is my PBIX file to help you see it work.

 

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Thanks a lot! Ed. That's what I am looking for.

Glad to help @River 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
JW_van_Holst
Resolver IV
Resolver IV

From the home tab choose Merge queries as new select the two tables and the columns that join them.

Hi JW,

 

How do you merge them into same column? It appears to me It's more of join.

 

Thanks,

River

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.