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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jmaur769
New Member

How to Correlate/Connect Two Tables with a Matching Column in Power Query

jmaur769_0-1727274768561.png

See tables here. I am trying to create a merged table to create a new table/query in Power Query that does the following:

- All rows from table 1 have at least one row, even if its empty

- each row from table 2 exists in a separate row

jmaur769_0-1727276529536.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jmaur769 ,
Thans for Ahmedx reply.
You can also try the following code

let
    Source1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrOyE9VitWJVjICcsITc3JSS8BcYyDXqSgzNS05sRiiwASsOrMIIm8K5HkkAtmxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Description = _t]),
    Source2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TYvLDcAwCEN34ZwLGGh3Qdl/jfJJpB4s4edHBDGtiYD2CpK8K2DtjtNzZ2uiP9LASm9gY3iWsth9wHOAQublvYYgjf0B", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Table 1 ID" = _t, Lot = _t]),
    MergedTables = Table.NestedJoin(Source1, {"ID"}, Source2, {"Table 1 ID"}, "Table2", JoinKind.LeftOuter),
    ExpandedTable = Table.ExpandTableColumn(MergedTables, "Table2", {"Lot"}),
    FinalTable = Table.ReplaceValue(ExpandedTable, null, "", Replacer.ReplaceValue, {"Lot"})
in
    FinalTable

Final output

vheqmsft_0-1727337717868.png

 

Best regards,
Albert He


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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @jmaur769 ,
Thans for Ahmedx reply.
You can also try the following code

let
    Source1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrOyE9VitWJVjICcsITc3JSS8BcYyDXqSgzNS05sRiiwASsOrMIIm8K5HkkAtmxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Description = _t]),
    Source2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TYvLDcAwCEN34ZwLGGh3Qdl/jfJJpB4s4edHBDGtiYD2CpK8K2DtjtNzZ2uiP9LASm9gY3iWsth9wHOAQublvYYgjf0B", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Table 1 ID" = _t, Lot = _t]),
    MergedTables = Table.NestedJoin(Source1, {"ID"}, Source2, {"Table 1 ID"}, "Table2", JoinKind.LeftOuter),
    ExpandedTable = Table.ExpandTableColumn(MergedTables, "Table2", {"Lot"}),
    FinalTable = Table.ReplaceValue(ExpandedTable, null, "", Replacer.ReplaceValue, {"Lot"})
in
    FinalTable

Final output

vheqmsft_0-1727337717868.png

 

Best regards,
Albert He


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

Omid_Motamedise
Super User
Super User

See this video including all you need to know about merging

 

https://www.youtube.com/watch?v=Nh0Ch-fQc_k&t=35s

 

 

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
Ahmedx
Super User
Super User

pls try

 

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
Top Kudoed Authors