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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Fill primary table using secondary table (join question)

Hello,

 

I have 2 tables I'd like to join. The secondary (table  B) should fill the primary (inserting rows) when merging with the priamry table (Table A). I'm having trouble because i need to scan through 2 fields from the second table, and merge it with the primary where it does not exist. See example belowTableExample.PNG

 

I do a right outer join on project key, and I'm getting my rows multiplied by 5 (5,000 total records).


Can anyone please help with this??

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

One sample for your reference, please check the following steps as below.

1. Add custom columns in both tables like this.

[Products]&[Severity]

2. Merge tables (LeftOuter) and fill the date column down.

 

2.PNGCapture.PNG

 

M code for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKTylNLlFwVNJRCk4tSy3KLKlUMFSK1cEhZYRbyhi3lAmKlBNuu5xw2+WE2y4nNLtiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Products = _t, Severity = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Products", type text}, {"Severity", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [Products]&[Severity]),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"Custom"}, TableA, {"Custom"}, "TableA", JoinKind.LeftOuter),
    #"Expanded TableA" = Table.ExpandTableColumn(#"Merged Queries", "TableA", {"Products", "Date"}, {"TableA.Products", "TableA.Date"}),
    #"Filled Down" = Table.FillDown(#"Expanded TableA",{"TableA.Date"})
in
    #"Filled Down"

PBIX as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

1 REPLY 1
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

One sample for your reference, please check the following steps as below.

1. Add custom columns in both tables like this.

[Products]&[Severity]

2. Merge tables (LeftOuter) and fill the date column down.

 

2.PNGCapture.PNG

 

M code for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKTylNLlFwVNJRCk4tSy3KLKlUMFSK1cEhZYRbyhi3lAmKlBNuu5xw2+WE2y4nNLtiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Products = _t, Severity = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Products", type text}, {"Severity", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [Products]&[Severity]),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"Custom"}, TableA, {"Custom"}, "TableA", JoinKind.LeftOuter),
    #"Expanded TableA" = Table.ExpandTableColumn(#"Merged Queries", "TableA", {"Products", "Date"}, {"TableA.Products", "TableA.Date"}),
    #"Filled Down" = Table.FillDown(#"Expanded TableA",{"TableA.Date"})
in
    #"Filled Down"

PBIX as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.