How do we compute the sum of the column values in excel?

After Read Range I am using the in Assign activity and getting the below error.

Any help is appreciated. Thanks!

String sum= dt.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Test Amt”).ToString.Trim)).ToString

1 Like

Dim sum As Double = dt.AsEnumerable().Sum(Function(row) row.Field(Of Double)("Test Amt"))

I get this error.

Assign: Cannot cast DBNull.Value to type ‘System.Double’. Please use a nullable type.

Dim sum As Double = dt.AsEnumerable().Sum(Function(row) row.Field(Of Double?)("Test Amt"))

No different than earlier.

Dim sumResult As Double = dt.AsEnumerable.Where(Function(row) Not IsDBNull(row.Item("Test Amt"))).Select(Function(row) row.Field(Of Double)("Test Amt")).Sum