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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

after union two table, data go to wrong column

when I union two same table, most data go to wrong column,  who know how to fix this error, thank you111Capture.PNG

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

You could modify the DAX for calculated table as:

Result Table =
UNION (
    SELECTCOLUMNS (
        Table1,
        "Column1", Table1[Column1],
        "Column2", Table1[Column2],
        "Column3", Table1[Column3]
    ),
    SELECTCOLUMNS (
        Table2,
        "Column1", Table2[Column1],
        "Column2", Table2[Column2],
        "Column3", Table2[Column3]
    )
)

That way can keep the same order for columns when you union two tables.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

9 REPLIES 9
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

This problem is caused by the different column orders of two tables.

 

The displayed column order in table view is not matched with that in the right fields pane. Please see below example:

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I know this is an old post but this may help others experiencing union problems. I found this tip re re-ordering columns in data view. Apparently the column order is determined by when the columns are added and not necessarily how you see them in Power Query. Tip: How to Change Column Order in Data View - Power BI - Enterprise DNA Forum

Anonymous
Not applicable

Yes, true, two table column have different order like your example, how to fix this without code ?

How to let data to show  with right side column order? 

in the Edit Query Mode, my table with same column order, how they change column order by Data tab?

Thank you for your help

Hi @Anonymous,

 

You could modify the DAX for calculated table as:

Result Table =
UNION (
    SELECTCOLUMNS (
        Table1,
        "Column1", Table1[Column1],
        "Column2", Table1[Column2],
        "Column3", Table1[Column3]
    ),
    SELECTCOLUMNS (
        Table2,
        "Column1", Table2[Column1],
        "Column2", Table2[Column2],
        "Column3", Table2[Column3]
    )
)

That way can keep the same order for columns when you union two tables.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

I have the same problem, and your solution would work just fine BUT I have ten tables each with ten columns. I would then need a cumbersome UNION SELECTCOLUMNS with 100 lines !!!

Do you know of any other way to ensure columns remain in the same order, thus avoiding this workaround ?

Excellent solution.

My tables were generated in DAX so I could not use power query to join

I tried union for a lot of tables and luckily the columns match up but sometimes they did not so this method helps me avoid being lucky in using union and rely on accurate coding instead.

 

Most Grateful  

Thank you so much. Your answer saving my lot of time...

Great answere ! very usfull.

parry2k
Super User
Super User

I never used union as such, did you tried using "append" in power queyr and see if it works.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.