Add column values of each Id in data table (1st row of each id)

How to add column values of IDs and store sum value it in first row of each id in table. Find the attached sample file screenshot.

Expected Output


1020 2 0 0 1 -add column values in 1 row
1020 1 0 0 1
1020 0 0 0 0
1002 2 4 4 1-add column values in 1 row
1002 0 2 0 1
1002 0 0 1 0

Same goes for 1002 id as well.

Hi @Sonalk ,

Welcome to the UiPath Forum.

Could you please elaborate on the requirement?

if you could present us with some sample data to work with(excel workbook) and an example of the output then we would be in a much better position to assist you.

Kind Regards,
Ashwin A.K

Hi @ashwin.ashok : Thanks for your reply.

I have provided attachment and explained problem statement and expected output.

Let me onow if you need more information.

Thats an interesting requirement you got there.

@Yoichi and @ppr , would you be so kind as to help us out there?

Kind Regards,
Ashwin A.K

1 Like


How about the following sample?

dt.AsEnumerable().GroupBy(Function(r) r("Id").ToString).ToList.ForEach(Sub(g) 
    g.First().Item("A")=g.Sum(Function(r) CDbl(r("A").ToString))
    g.First().Item("B")=g.Sum(Function(r) CDbl(r("B").ToString))
    g.First().Item("C")=g.Sum(Function(r) CDbl(r("C").ToString))
    g.First().Item("D")=g.Sum(Function(r) CDbl(r("D").ToString))
End Sub) (8.8 KB)


1 Like

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