How could i deal with the excel file problem? add the row data

I have a excel file like this
1
in column a ,if the cell is same and in column c the data1 is the same, then add the data2 into one cell ,the result like this
2
anyone could help me ? give me a demo xaml code, thanks a lot in advance!!!

pay attention: only the row name is the same , and the number in row data1 is the same, we just add the number in data2, if name is the same,but the number in data1 is not the same ,we do not add, anyone could help me ? thanks a lot in advance!!!

Hi @chrisjiyiwei

Try with the LINQ expression

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

Regards
Gokul

hey dear Gokul001 ,could you give me a UiPath xaml code demo ? thanks a lot !!!

Hi @chrisjiyiwei

Check out the XAML file

LINQ_GRPBY.xaml (8.3 KB)

Regards
Gokul

Dt_Clone variable type is datatable?

Yes @chrisjiyiwei Check out the XAML file

i could not open the xaml file , it shows document is invalid

what is the read range excel output datatable ?

is it the dt_clone ?

I mean what is the read range output datatable? is it dt_input?

Yes @chrisjiyiwei

Read range - Dt_input
Write rnage = Dt_Output

i run the code , it generates the error as follow
Assign: Input array is longer than the number of columns in this table

Try with this one

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

another error Assign: Object reference not set to an instance of an object

Can you share the screenshot of you XAML file? @chrisjiyiwei

hi gokul

just the same problem wanna to help me 。
only the row name is the same and the row data 1 is the same ,just add the row data 2 number, how could i change the (From d In currdt.AsEnumerable Group d By k=d(“a”).toString Into grp = Group Let nj = String.Join(“+”,grp.Select(Function (n) n(“data2”).toString)) Let ra = New Object(){k,grp.First()(1),grp.First()(2),nj} Select r = dtclone.Rows.Add(ra)).CopyToDataTable

hey Gokul ,

just the same problem wanna to help me 。
only the row name is the same and the row data 1 is the same ,just add the row data 2 number, how could i change the (From d In currdt.AsEnumerable Group d By k=d(“a”).toString Into grp = Group Let nj = String.Join(“+”,grp.Select(Function (n) n(“data2”).toString)) Let ra = New Object(){k,grp.First()(1),grp.First()(2),nj} Select r = dtclone.Rows.Add(ra)).CopyToDataTable

Hi @chrisjiyiwei

Check on the below thread

Cheers!!