Forum Discussion
UNION tables
Hey,
I wanted to use union to combine four tables, all with different number of columns and different column values, apart from one same column of 'code number' among all columns. How to do that?
Please help me out
Thanks!
7 Replies
- HotChilliCommunity Champion
I don't think you can use UNION for this.
Maybe a merge in Power Query but perhaps you can explain further your desired result? with an example?
- 123117Frequent Visitor
Hey,
Thanks for your reply
Here's an example of the tables, the columns are separated by |
All tables have different number of columns
Table 1
Code | Description | X | Y | Z
Table 2
Code | Description | A | B | C | D | E
Table 3
Code | Description | Date | L
Table 4
Code | Description | R | S | T | U | V | W
Result output:
Code | Description | X | Y | Z | A | B | C | D | E | Date | L | R | S | T | U | V | W
Basically the result should be all the columns combined and then Ill add some measures too
And all the columns combined with values corresponding to the code.
- HotChilliCommunity Champion
Yes, that would be a merge
https://docs.microsoft.com/en-us/power-query/merge-queries-overview
using Code as the joining field
- 123117Frequent Visitor
Hey,
But can I use something else? Like relationship or multiple UNIONS or DAX or something?
- AnonymousNot applicable
HI 123117,
You can try to nested use UNION and SELECTCOLUMNS functions to shape and transform your tables to similar structures before using the UNION function.
UNION function (DAX) - DAX | Microsoft Docs
SELECTCOLUMNS function (DAX) - DAX | Microsoft Docs
Regards,
Xiaoxin Sheng