Excel sum of column query

I’ve got a problem with the solution provided in this post. Creating a new topic since the original post is closed.

The query doesnt not provide the correct value all the time. Am I missing something. Please help


The sum of the above value is 0. But the query result is 2.91038304567337E-11

Below is the query used:
dt_t1.AsEnumerable.Sum(Function ® If(IsNumeric(r(“Column13”).ToString.Trim), CDbl(r(“Column13”).ToString.Trim), 0))

@chenderson Can you please help?


If i see correctly above values gives a sum of 1.2 not 0, and you can change Double type value to Decimal. Decimal type should be use for financial operations.

The decimal keyword indicates a 128-bit data type. Compared to floating-point types, the decimal type has more precision and a smaller range, which makes it appropriate for financial and monetary calculations.

So query you should use is: dt_t1.AsEnumerable.Sum(Function ® If(IsNumeric(r(“Column13”).ToString.Trim), CDec(r(“Column13”).ToString.Trim), 0))

Thank you @rado. I will test and get back to you

@rado… Thank you. Your solution solved my problem.

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