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

Hi guys,

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:

help me to achieve this

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 ,

@geetanjali.nerlekar

Can you please send the error description?

@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}

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.