I'm getting 2.8421709430404E14 while summing instead of 0 in uipath

My code is (From d in OriginalDataTableVar.AsEnumerable
Group d by k=d(0).toString.Trim Into grp=Group
let res = grp.Sum(Function ® CDbl(r(“Amount”).toString.Trim))
Select dtResult.Rows.Add({k,res})).CopyToDataTable

Name Amount
Apple. -65.54
Apple. 54.61
Apple. 65.54
Apple. -54.61

Instead of sum value 0 I’m getting as 2.8421709430404E14
Anyone please help me

Hi @brindhaS,

Can you try using CDec instead of CDbl?

Hi @brindhaS,

Use following code in assign,

  1. When to sum all values from column Amount.
Sum = (DT.AsEnumerable().Sum(Function(i) CDbl(i("Amount").ToString)))
  1. When to sum Amount where, Name value is an Apple.
Sum = (DT.AsEnumerable().Where(function(x) x("Name").ToString.Equals("Apple.")).Sum(Function(i) Convert.ToDouble(i("Amount").ToString)))