Forum Discussion

dsbuilder's avatar
dsbuilder
New Member
5 years ago
Solved

Need to fetch multiple values from the same table

Hello, I have a problem that I believe it's simple but I haven't been able to do this.  Imagine a table like this L1column L2column Number_ext 1.1 Rice     1.1 Rice 1.1.1 Blue Rice F...
  • Jimmy801's avatar
    5 years ago

    Hello dsbuilder 

     

    check out this solution. It uses Table.Group and AddColumn. This will write your requested data in every column, no only in the first 🙂

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQzVAjKTE5V0lFSAONYHRRBIBPIccopTYWJuHmGuWJTZaTgXpSamocwDaLGSCEgvySxJD+1GM0KFAkgF2iaf04KsmBIuKsPdrtQXRTi6qej4OrjGubqR1gx0PpYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [L1column = _t, L2column = _t, Number_ext = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"L1column", type text}, {"L2column", type text}, {"Number_ext", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"L1column"}, {{"AllRows", each _, type table [L1column=text, L2column=text, Number_ext=text]}}),
        #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Conc", each Text.Combine([AllRows][#"Number_ext"])),
        #"Expanded AllRows" = Table.ExpandTableColumn(#"Added Custom", "AllRows", {"L1column", "Number_ext"}, {"L1column.1", "Number_ext"})
    in
        #"Expanded AllRows"

     

    Copy paste this code to the advanced editor in a new blank query to see how the solution works.

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy