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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Employee
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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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