How to add values of different rows for same name using LINQ queries?

Hi All,

Can someone help me in adding all the values of one user in below DT using LINQ quires ?

Input Data table

In the above data table I have to add UIST values 37+43 and want to convert into one row … Similarly for BOT store values 12 +21 should get added and want to convert into one row like below screenshot

Expected Out put data table

@J0ska @kumar.varun2

Hi @Mandava_Naresh

How about this expression?

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

Regards
Gokul

Hello @Mandava_Naresh ,

Besides @Gokul001 'solution, please check these two topics:

It should help you to understand what your are using within your UiPath project.

Best regards,
Marius

HI @Mandava_Naresh

Check out this XAML file

GroupBySumBuildDt.xaml (8.1 KB)

image

Output

image

Regards
Gokul

1 Like

Hi @Gokul001 ,

It worked … Thank you very much

Can we convert the value from string to int before we add values?

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