How to sum the amount of duplicate ID's

Hi All,

Kindly find the below input sheet,
image
and i want output as same as below
image

It should check the whether the ID and corresponding wage type is same then i need to sum the amount of corresponding ID and wage type, please help me

Hi,

Can you try the following?

img20220131-3

deResult = dt.AsEnumerable.GroupBy(Function(r) Tuple.Create(r("Emp-Id").ToString,r("Wage type").ToString)).Select(Function(g) dt.Clone.LoadDataRow({g.Key.Item1,g.Sum(Function(r) Int32.Parse(r("Amount").ToString)).ToString,g.Key.Item2},False)).CopyToDataTable()

Sample20220131-2.zip (4.6 KB)

Regards,

Hi

Have a view on this thread on similar note and suggestions

Cheers @bhanu.priya2

1 Like

Hi @bhanu.priya2

Try the below expression for removing Duplicate values and copy the unique values in the DT

(From p in DT.Select() where( From q in DT.Select() where q(“Emp-id”).Equals(p(“Emp-id”)) Select q).ToArray.Count>1 Select p).ToArray.CopyToDataTable()

Regards
Gokul

Can You Explain me how this work

xlWorkSheet1.Range(SourceCellValue).Copy()
xlWorkSheet6.Range(SourceCellValue).PasteSpecial(XlPasteType.xlPasteValues, XlPasteSpecialOperation.xlPasteSpecialOperationNone, False, False)

1 Like

Thank you so much Yochi, it is working super fine :slight_smile:

1 Like

Thanks for the reply checked your solution also and it is working fine

1 Like

Thank you for your reply

Thank you palaniyappan, i got the solution

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