Using LINQ to build table sum by staff no

ensure you have an empty target datatable in place - dtTarget
this can be e.g. created with the build datatable activity and defining 2 cols: Staff_No, Sum

use an assign activity:
LHS: dtTarget
RHS:

(From d In dt_pymt_table_ori.AsEnumerable()
Group d By k= d(“Staff_No”).toString.Trim Into grp=Group
Let s = grp.Sum(Function( x ) Double.Parse(x(“Paid_Amt”).ToString))
Let ra = new Object(){k,s}
Select r=dtTarget.Rows.Add(ra)).CopyToDataTable

Other outputs e.g. a dictionary would be possible as well

Also have a look here:

1 Like