Help adding rows to each other in data table

I have a data table im pulling and it gives me something that looks like this. On the left I have some duplicate numbers. So i need to find all the ones that match on the left and take the sum of all the numbers to the right of it and have one row for that number. So for the first one it would get rid of 6 of the 100012 and just keep one with 2,870 in the other row.

100012 410
100012 410
100012 410
100012 410
100012 410
100012 410
100012 410
100013 1750
100013 1750
100013 1750
100013 1750
100013 1750
100013 1750
100013 1750
100013 1750
100013 1750
100013 1750
100013 1750
100013 1750
100013 1750
100014 8780
100014 8780
100014 8780
100014 8780
100014 8780

we can do it with the help of a group by

prepare the report table with build datatable (configure two or needed coumns)
OR
Assign activity
LHS: dtReport | datatable
RHS: YourOriginDataTable.Clon

then use again an assign Activity
LHS: dtReport
RHS:

(From d in YourOriginDataTable.asEnumerable
Group d by k=d(0).toString.Trim into grp=Group
Let s = grp.Sum(Function (x) CInt(x(1).toString.Trim))
Let ra = new Object(){k,s}
Select r=dtReport.Rows.Add(ra)).CopyToDataTable

Also have a look here:

Try Below Seq:

Read Data - DT
Assign UniqueDT= DT.defaultview.totable(true,“ID”) – here i assume 1st column is ID
Build Datatable as DT_Out → same columns
For Each row —> UniqueDT
Filter Data Table —> DT as input and DT2 as output
Condition as —> column 0 = row(0).tostring
Assign ----> Total=0
For each row —> DT2
Total=TOTAL+ROW(1).TOSTRING
after 2nd for each use Add data row for DT_Out with Array Row as ----> {Row(0).tostring,Total}

You will get final data in DT_Out

Regards,
Prathamesh

Hey can you expand on this. Im still sort of confused when trying to follow along

Try to create workflow as I mentioned and check if you have any queries then send me your workflow so i can make changes

its about the non LINQ approach also mentioned in the HowTo shared with you above:

Check this sample for reference
Test.xaml (13.2 KB)

you will see following:

whne updating the packat ot following version:
grafik

1 Like

image

image