Forum Discussion
after union two table, data go to wrong column
- 8 years ago
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
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
- Anonymous5 years agoNot 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 ?
- Hisham7 years agoFrequent Visitor
Great answere ! very usfull.
- Narukkp7 years agoHelper V
Thank you so much. Your answer saving my lot of time...
- dennissheehan7 years agoFrequent Visitor
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