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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Conditional data source join

Hi All,

 

I have 2 data sources and in both of them thare are columns NAME and ID. I would like to do a conditional join such as:

If NAME and ID are equal in both data sources join it based on these 2 columns; if not join it only based on NAME column.

 

If anybody can provide code from advance editor I would be very greatful.

 

Thanks

1 ACCEPTED SOLUTION
AUDISU
Resolver III
Resolver III

@Anonymous 

Try following code.

#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Id", "Name"}, Table2, {"ID", "Name"}, "Table2", JoinKind.LeftOuter),
#"Merged Queries1" = Table.NestedJoin(#"Merged Queries", {"Name"}, Table2, {"Name"}, "Table2.1", JoinKind.LeftOuter),
#"Added Custom" = Table.AddColumn(#"Merged Queries1", "Custom", each if Table.RowCount([Table2]) > 0 then [Table2] else [Table2.1])
in
#"Added Custom"

 

AUDISU_0-1664278453550.png

 

View solution in original post

1 REPLY 1
AUDISU
Resolver III
Resolver III

@Anonymous 

Try following code.

#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Id", "Name"}, Table2, {"ID", "Name"}, "Table2", JoinKind.LeftOuter),
#"Merged Queries1" = Table.NestedJoin(#"Merged Queries", {"Name"}, Table2, {"Name"}, "Table2.1", JoinKind.LeftOuter),
#"Added Custom" = Table.AddColumn(#"Merged Queries1", "Custom", each if Table.RowCount([Table2]) > 0 then [Table2] else [Table2.1])
in
#"Added Custom"

 

AUDISU_0-1664278453550.png

 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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