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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Joining tables with Union and different columns

I want to use DAX to UNION 3 tables together. My issue is that 2 of the tables contains split columns...

Table1

ColumnA ColumnB ColumnC

 

Table2

ColumnA ColumnB

 

Table3

ColumnC

 

So normally, I could use 

UNION(
  SELECTCOLUMNS(Table1, "Title", ColumnA, "Name", ColumnB),
  SELECTCOLUMNS(Table2, "Title", ColumnA, "Name", ColumnB)
     )

But how can I incorporate ColumnC from Table1 and from Table3?

I'd like to use DAX and not have to merge via Power Query. 

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Anonymous 

please try

=
UNION (
UNION (
SELECTCOLUMNS (
Table1,
"Title", Table1[ColumnA],
"Name", Table1[ColumnB],
"Value", Table1[Columnc]
),
SELECTCOLUMNS (
Table2,
"Title", Table2[ColumnA],
"Name", Table2[ColumnB],
"Value", BLANK ()
)
),
SELECTCOLUMNS (
Table3,
"Title", BLANK (),
"Name", BLANK (),
"Value", Table3[Columnc]
)
)

Anonymous
Not applicable

for some reason, this produced blank rows for Table3[ColumnC] values that match to Table2[ColumnA] and Table2[ColumnB] - the values for  Table3[ColumnC] did not pull in at all. 

@Anonymous 

Yes it happens sometimes. First adjust the code as follows (make sure the order of the columns in the code is correct)

=
UNION (
SELECTCOLUMNS (
Table1,
"Title", Table1[ColumnA],
"Name", Table1[ColumnB],
"Value", Table1[Columnc]
),
SELECTCOLUMNS (
Table2,
"Title", Table2[ColumnA],
"Name", Table2[ColumnB],
"Value", BLANK ()
),
SELECTCOLUMNS (
Table3,
"Title", BLANK (),
"Name", BLANK (),
"Value", Table3[Columnc]
)
)

 

If this didn't work, copy the code and create a new table then delete the old one. 

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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