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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
josedagadea
New Member

Help on a very specific and interesting join of 3 tables

How can I make this join efficiently?

 

I have 3 tables. For the sake of simplicity, assume each column in this table is a separate table, and the rows below are the values I want to join in each table:

 

Table ATable BTable C
adf
fac
aff

 

As you can see, there are some repeating values as seen in table A, the value "a". I want to make a join in a way that the matching values appear in the same row for all of the 3 tables, AND for the values that do NOT match, have a null resulting value in the other columns like:

 

Table ATable BTable C
aanull
anullnull
nullnullc
nulldnull
fff

 

Note that the repeating value in table A is taken into account as another row and compared again with the other tables.

 

Any help would be great. I haven't found an efficient way to do this.

1 REPLY 1
AlienSx
Super User
Super User

with your simplified table I would go this way

let
    Source = #table({"Table A", "Table B", "Table C"}, {{"a", "d", "f"}, {"f", "a", "c"}, {"a", "f", "f"}}),
    cols = List.Buffer(Table.ColumnNames(Source)),
    values = List.Distinct(List.Combine(Table.ToList(Source, (x) => x))),
    tx = List.Transform(
        values,
        (x) => List.Zip(
            List.Transform(
                cols, 
                (w) => ((lst) => if lst = {} then {null} else lst)(List.Select(Table.Column(Source, w), (z) => z = x))
            )
        )
    ),
    result = Table.FromList(List.Combine(tx), (x) => x, cols)
in
    result

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors