How to group the row and add the values in the row and copy it to the same datatable

Below mentioned the input and output I needed…(query is preferable)
Name value
Lisa 1122
Muno. 1233
Hura. 1156
Lisa. 456

Lisa 1567
Muno 1233
Hura. 1156

Hey @Demo_User ,

You can do the pivot table using LINQ to get the expected output. Have a look at this LINQ | LINQ Pivot Table Aggregation | Sum LINQ Pivot | LINQ Uipath | Uipath Tutorials | Coderslobby - YouTube


Hi @Demo_User

Welcome to our community

Give a try with

(From row In dtInput.AsEnumerable
Group row By sc = row(“Name”).ToString()
Into grp = Group
Let total= grp.sum(Function (x) Convert.ToDouble(x(“Value”).ToString()))
Let result = New Object() {grp(0)(“Name”),total}
Select dtToWrite.rows.add(result)).CopyToDataTable



Welcome to the community

Please try this in assign activity with the below given formula on right and on left dtoutput…

dtoutput = (From d In dtinput.AsEnumerable() Group d By k=d("Name").toString.Trim Into grp = Group Let sum = grp.sum(function(x) cdbl(x("Value"))) Let ra = New Object(){k,sum} Select r = Dtoutput.Rows.Add(ra)).CopyToDataTable()

Before this use another assign with

Dtoutput = dtinput.Clone()

And if not working please confirm if your project is in c# or



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