Linq group by and concatenate

hello everyone,

I need to group the rows in which columns A,B and C are equal.

Then I would like to aggregate the values of the OLD and NEW columns.

In the image, at the top the original datatable and at the bottom the one I expect.

I cannot find a suitable linq, can you help me?

please fallow these steps,
1-use read range activity
2-use filter data and set keep and give input and output data table.
3 further i am looking

This is the syntax used:

(From d In outDt.AsEnumerable
Group d By k=d(“A”).toString.Trim, k1=d(“B”).toString.Trim, k2=d(“C”).toString.Trim Into grp=Group
Let n = String.Join(“,”,grp.Select(Function (x) x(“old”).toString.Trim).toArray)
Let f = String.Join(“,”,grp.Select(Function (x) x(“New”).toString.Trim).toArray)
Let ra = New Object(){k,k1,k2,n,f}
Select dtReport.Rows.Add(ra)).CopyToDataTable

It works, the problem is: if i’ve some other columns to display in the new DT, how do I insert them into the new object?

Hi @andreus91 ,

If my assumption is right, you would want to add also other columns which are already available in the Original DT, then you could add the column values using the row object d that you have created.

Let ra = New Object(){k,k1,k2,n,f,d("YourRequiredColumn").ToString}

But the Output Datatable dtReport also need to have the number of Columns available to include this value.