Forum Discussion

mhmmd_srf's avatar
mhmmd_srf
Regular Visitor
1 year ago
Solved

Convert Column into rows with concatenation

Hi All, I have data set like below: And I want data set like below from abouve one: I need this using Power Query. Can anyone please help me on this. Thanks, MS
  • v-dineshya's avatar
    v-dineshya
    1 year ago

    Hi mhmmd_srf ,

    Thank you for reaching out to the Microsoft Community Forum.

     

    Please follow below steps.

     

    1. Imported sample data, that you have provided. Please refer snap.

     

    2.  In Power Query editor ,  New sources ---> Blank Query  and click on "Advanced editor" delete the complete code and paste below M code.

     

    let

    Source = Table.FromRows({
    {"123", "11", 10},
    {"123", "22", 20},
    {"123", "33", 30},
    {"123", "44", 40},
    {"789", "66", 70},
    {"789", "77", 10}
    }, {"mat_nbr", "ship_plant", "qty"}),


    ChangedType = Table.TransformColumnTypes(Source, {
    {"mat_nbr", type text},
    {"ship_plant", type text},
    {"qty", Int64.Type}
    }),


    Grouped = Table.Group(ChangedType, {"mat_nbr"}, {
    {"ship_plant", each Text.Combine([ship_plant], ","), type text},
    {"qty", each List.Sum([qty]), Int64.Type}
    })
    in
    Grouped

    3.  Please refer below output snap and attched PBIX file.

     

     

     

    I hope this information helps. Please do let us know if you have any further queries.

     

    Regards,

    Dinesh