Forum Discussion

jerryr125's avatar
jerryr125
Helper IV
1 year ago
Solved

Single record with concatenated data (field)

Hi - 

I have the following data in which I would like to run through Power Query to create a single record for each ID.

 

Example:

 

Data Start (Table A)

IDItem
1Pizza
1Hamburger
2Banana
3Ice Cream
3Pizza
3Apple
3Bread
4Rice
4Pasta


New Table (Table B) - after running through Power Query:

 

,

IDItem
1Pizza; Hamburger
2Banana
3Ice Cream; Pizza; Apple; Bread
4Rice; Pasta



Any thoughts on how this can be accomplished ?

Thanks - Jerry

  • right click on the Id column and pick group by command and make the setting presented in the next image

     

     

     

    press ok will result in error in the new column as it is not posible to apply sum operation on the text as the next

     

     

     

    in the formula replaced list.sum by Text.combine to reach the next

     

     

     

    if you want to use seperator also write the formula as bellos.

     

    Text.Combine([Item],"; ")

     

     

     

     

     

     

4 Replies

  • p45cal's avatar
    p45cal
    Solution Supplier

     

    let
        Source = Excel.CurrentWorkbook(){[Name="JerrysTable"]}[Content],
        GroupedRows = Table.Group(Source, {"ID"}, {{"Item", each Text.Combine(_[Item],"; ")}})
    in
        GroupedRows
  • right click on the Id column and pick group by command and make the setting presented in the next image

     

     

     

    press ok will result in error in the new column as it is not posible to apply sum operation on the text as the next

     

     

     

    in the formula replaced list.sum by Text.combine to reach the next

     

     

     

    if you want to use seperator also write the formula as bellos.

     

    Text.Combine([Item],"; ")

     

     

     

     

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jerryr125 ,

    Both answers of p45cal and Omid_Motamedise are great! Please remember to accept the reply as solution if you have solved your problem to help more others facing the same problem to find a solution quickly, thank you very much!

    Best Regards,
    Dino Tao