Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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 the...
  • AUDISU's avatar
    3 years ago

    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"