How to calculate the sum of weights only of duplicate values from column SONum?

Hi guys,
image
We have 3 duplicate cells in SONum column, firstly i have to get the sum of the weights associated with duplicate values that is 58+58+54 and later i have to remove all the duplicate rows and keep the total sum of weight.

The output should look like this:
image

help me to achieve this

Hi @geetanjali.nerlekar

Editing the previous query & attaching the workflow along with the file. Please do refer the same.

forumSample.zip (152.9 KB)

Hope this helps,
Best Regards.

Hi @arjunshenoy ,


please help me to remove errors

@geetanjali.nerlekar

Can you please send the error description?

@arjunshenoy

@geetanjali.nerlekar
Yes. you should use assign activity.

In the left hand side of assign acitivity you should use dt2, in the right hand side you should use Linq.

Also see below updated linq:
(From row in dt1.AsEnumerable
Group row by sc = row(“SoNum”).ToString()
Into grp = Group
Let total= grp.sum(Function (x) Convert.ToDouble(x(“Weight”).ToString().Trim()))
Let result = New-Object() {grp(0)(“SoNum”),total}
Select dt2.rows.add(result)).CopyToDataTable

@arjunshenoy

Hi @geetanjali.nerlekar,
Refer to the attached workflow to get an idea on your use case
GroupSum.xaml (8.9 KB)

@geetanjali.nerlekar

I modified the previous post where in mentioned the query & made the complete workflow for your reference. Please do check it out & let me know if it works.

Hope this helps,
Best Regards.

This works… thankyou so much @vishal.kp

1 Like

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