Combine duplicate rows into single row based on column value

I am trying to combining duplicate rows into one row based on column value. If Two rows have same data and if “Location” Column have different values the Combine two rows and “Location” Should be in one row

Original Data:

Name company Location
Ramesh abc chennai
Raju ghi hyderabad
Ramesh abc pune
Ruteesh xyz mumbai
Krishna dcf noida
Krishna dcf hyderabad
Name company Location
Ramesh abc chennai, pune
Raju ghi hyderabad
Ruteesh xyz mumbai
Krishna dcf noida, hyderabad

Hi @ruteesh_raju

Welcome to Uipath community

How about this expression?

DtOutput = DtBuild.Clone

(From d In DtBuild.AsEnumerable
Group d By k=d("Name").toString.Trim Into grp = Group
Let nj = String.Join(",",grp.Select(Function (n) n("Location").toString.Trim))
Let ra = New Object(){k,grp.First()(1),nj}
Select r = DtOutput.Rows.Add(ra)).CopyToDataTable

Regards
Gokul

Sample Reference XAML file

DuplicateTwoColumn.xaml (9.1 KB)

Regards
Gokul

1 Like

Have a Look Here at different approaches for grouping Data

Hi @ruteesh_raju

If it working, Kindly close this topic by mark as solve. It will help for other too

Regards
Gokul

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.