Forum Discussion

mraka9's avatar
mraka9
Icon for Helper III rankHelper III
3 years ago
Solved

How to link related items?

Greeting, I need help regarding the table below. I have a column: Product A i Product B. I want to get the result for Product C. I need in Power Query that based on Product B, Product A is sear...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi mraka9 

    You can put the following code in Advanced Editor in power query:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8s1PysxJ1TUyUdKBsQ2NlGJ1opWcE4t0DY2BwiCGOVgIoUAHSSNMsTlUraEBWMgjv7Q4VdfYACgKYRoZYSo1RlJqZARXamyAyz5ToEwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Product A" = _t, #"Product B" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product A", type text}, {"Product B", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", (x)=>Text.Combine(Table.SelectRows(#"Changed Type",(y)=>y[Product A]=x[Product B] )[Product B] ,",")       )
    in
        #"Added Custom"

    Output:

    Best Regards!

    Yolo Zhu

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