simplest way in Excel to combine (merge)

ValentinCVE

New Member
Joined
Mar 23, 2024
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
What is the simplest way in Excel to combine (merge) multiple rows data corresponding to a unique value in large dataset? output should be: x=a,b,c,d. Already tried power pivot, pivots.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Probably the easiest method will be by using Power Query.

So:
1) Data-> Get& Transform ... -> From Table/Range (or any other source) and show the source

2) Then PQ editor opens and if the column with data which you want to merge is tot text type click on Content Type icon left to column name on icon header and select text type. if it is already a text (icon Reads ABC) skip this step.

3) Use Transform->Group by -> Basic and use column with identifiers and your data to be concatenated, then you may write your desired column name (I used "Concatenated") than (it's a trick) use Max as operation and your data to be concatenated as Column

4) in advanced editor or just in formula bar change List.Max into Text.Combine and after column with text to be combined add comma and the separator (I used comma and space, but of course coma only is also fine.

5) From Home use Close and Load or Load To


This is the m code which was registered (much shorten than the written description):

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"value", type text}}),
//    this is how it was registered with Max: #"Grouped Rows" = Table.Group(Source, {"id"}, {{"Concatenated", each List.Max([value]), type any}})
    #"Grouped Rows" = Table.Group(#"Changed Type", {"id"}, {{"Concatenated", each Text.Combine([value], ", "), type any}})
in
    #"Grouped Rows"

I'd say this method is 2 steps only, because only steps 3 and 4 above are "real actions" The whole thing is done with about dozen of clicks of mouse and writing 3 words. So really simple.
 

Attachments

  • Zrzut ekranu 2024-03-23 172441.png
    Zrzut ekranu 2024-03-23 172441.png
    33.4 KB · Views: 9
Upvote 1
Solution
Thank you very much for the answers. Kaper, your method helped me the most. I asked this question on 3 forums and a better solution than the one given by you was not offered to me. Thank you very much for your help.
 
Upvote 0
Welcome to the MrExcel Message Board!

For future reference.
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,223,631
Messages
6,173,465
Members
452,516
Latest member
archcalx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top