Hello , Here I mentioned the sample input of my reqirement, where I need to find duplicate in “RollNo” and get thier corresponding values in Column “Name” and Add the string into single cell of Column “Name” Input
Linq I used
(From G In BuildDT.AsEnumerable
Group By O = New With {Key.K = G.Item(“RollNo”), Key.U = G.Item(“RollNo”)}
Into Group Select Group(0)).ToArray().copytodatatable()
(From row In dt1.AsEnumerable
Group row By key = New With {
Key.name = row.Item("Name")} Into grp = Group
Select dt1Clone.LoadDataRow(New Object() {
key.name,
String.Join(" ",grp.Select(Function(x)x("Address").ToString).ToArray)
}, True)).CopyToDataTable
Assumption - dtResult = BuildDT.Clone or prepared datatable with e.g. build datatable
we can simplify to
(From d In BuildDT.AsEnumerable()
Group d By k=d("RollNo").toString().Trim() Into grp = Group
Let nj = String.Join(",", grp.Select(Function (n) n("Name").toString.Trim))
Let ra = new Object(){nj,k}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable
@ppr , Thanks for your instatnt response, from your expression I can get what i expected, but only 2 columns only I’m able to get data.
In case of multiple columns having same row data values except one column(which has different data) how can use your Expression and add the different data string. Same scenerio I already mentioned above, That is 2 column, I need it for 7 columns, where 6 columns are unique and 7 th column is Different data , need to add all string in single cell and remove other
I attached my sample Excel sheets here , it contains 2 sheets of input and output sheets Sample (4).xlsx (9.1 KB)