Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Merge tables, adding new values

Dear community,

I need a help merging two tables yet adding new values, as shown in the picture below

The Stock table should be left outer join. So the new tables should include all values from table Stock, respective Inbound for matched articles and new articles from table Inbound with respective values.

Would be grateful for any tips! 

  • let
        Stock = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTJSitWJVnKCs5whrFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Article = _t, Stock = _t]),
        Inbound = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTJUitWJVnKGs1zgLDcIKxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Article = _t, Inbound = _t]),
        #"Merged Queries" = Table.NestedJoin(Stock, "Article", Inbound, "Article", "In", JoinKind.FullOuter),
        #"Expanded In" = Table.ExpandTableColumn(#"Merged Queries", "In", {"Article", "Inbound"}, {"Article.1", "Inbound"}),
        #"Combined Columns" = Table.CombineColumns(#"Expanded In", {"Article.1", "Article"}, each if _{0} = _{1} then _{0} else _{0}??"" & _{1}??"", "Article")
    in
        #"Combined Columns"

3 Replies

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion
    let
        Stock = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTJSitWJVnKCs5whrFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Article = _t, Stock = _t]),
        Inbound = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTJUitWJVnKGs1zgLDcIKxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Article = _t, Inbound = _t]),
        #"Merged Queries" = Table.NestedJoin(Stock, "Article", Inbound, "Article", "In", JoinKind.FullOuter),
        #"Expanded In" = Table.ExpandTableColumn(#"Merged Queries", "In", {"Article", "Inbound"}, {"Article.1", "Inbound"}),
        #"Combined Columns" = Table.CombineColumns(#"Expanded In", {"Article.1", "Article"}, each if _{0} = _{1} then _{0} else _{0}??"" & _{1}??"", "Article")
    in
        #"Combined Columns"

  • Anonymous's avatar
    Anonymous
    Not applicable

    thanks for help everyone!