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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Artefact
Helper II
Helper II

Combine 3 tables in DAX

I have to combine a colum from 3 separate tables into one table with all combinations :
So this must be the end result
So it must only be the combinations which are present in the data, NOT ALL possible combinations, so CROSSJOIN alone doesn't do the job in my opinion.

 

from table 1from table 2from table 3
AAA
BBnull
CnullC
nullDD
Enullnull
nullFnull
nullnullG
9 REPLIES 9
v-yangliu-msft
Community Support
Community Support

Hi  @Artefact ,

 

Here are the steps you can follow:

1. Create an Index for each table..

In Power Query -- add Column – Index Column – From 1.

vyangliumsft_0-1706691616156.jpeg

2. Create calculated table.

Table =
var _table=
SUMMARIZE(
    'Table1','Table1'[Index],'Table1'[from table 1],
    "from table 2",LOOKUPVALUE('Table2'[from table 2],'Table2'[Index],'Table1'[Index]),
    "from table 3",LOOKUPVALUE('Table3'[from table 3],'Table3'[Index],'Table1'[Index]))
return
SUMMARIZE(
    _table,[from table 1],[from table 2],[from table 3])

3. Result:

vyangliumsft_1-1706691616157.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

tb1tb2tb3

A

AA
BBC
CDD
EFG

 

Hello Liu,
Thanks for your reply. Almost done, but I presented my initial tables somewhat different as intended. The null values aren't exactly on the rows as in the first post. The null values are not there at all, I just wanted to show the nulls in the end result. So the table above is the right starting point for obtaining the result table. Hope thsi helps, and thanks again for your efforts!

Dangar332
Super User
Super User

hi, @Artefact 

try to use intersect() function

you nedd intersect twice for combine 3 table

Artefact
Helper II
Helper II

addendum :

So basetable 1 has a column with only ABCE, table 2 ABDF and table 3 ACDG.
I don't want a cartesian product with CROSSJOIN, that would result in a much bigger table

Ok, now I get what you want. You want a Full Outer Join.

 

Unfortunately, DAX does not support this kind of join operation as far as I'm aware, so if you can't push this operation to Power Query (which indeed supports Full Outer Joins Full outer join - Power Query | Microsoft Learn) then the only solution that comes to my mind is a not so elegant workaround, which is the following:

  1. Do a NATURALLEFTOUTERJOIN between Table1 and Table2, let's call it Join1
  2. Do a NATURALLEFTOUTERJOIN between Table2 and Table1 (the order is important), let's call it Join2
  3. Do first an UNION and then a DISTINCT between Join1 and Join2, let's call the resull FinalJoin
  4. Repeat this process between FinalJoin and Table3

Let me know if it works for you.

 

Thanks Lorenzo, seems like your idea works, but I need the full code for your solutions. I don't understand were I put the UNION and DISTINCT functions. Seems like these functions don't work with 2 (distinct) or 3 (union) columns in my code.

Lorenzo994
New Member

Hi, it's not very clear what is the starting point and what is the end result.

 

What is the criteria to join the table? You are saying in the same message that you expect all possible combination and right after that you do not want all possible combinations, so it quite hard to understand what you are looking for.

Artefact
Helper II
Helper II

The result is the table in the post

Ahmedx
Super User
Super User

show what result you expect

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.