Sum Datatable using Activity DataTable Manipulation

Hello All,

i had some research to SUM datatable from certain column in excell, i found that activity DataTable Manipulation can cover it.

Already tried it but had some error :
Math Operations: Cannot cast DBNull.Value to type ‘System.Double’. Please use a nullable type.

here the Screenshoot :

Note :
Output Value (dt_test) using Variable type Double.

anyone please help me recommend solution to SUM value from certain column in datatable excel?


Hi @aliaga
do your column had null values ?

yes my column had null values

Hi @aliaga
i dont know which activity activity you are using , but you can try this linq query in the assign activity . It will handle the null values too using If

sum = dt1.AsEnumerable().Sum(Function(row) If(row(“Oct_2020”).ToString.Equals(“”),0,CDbl(row(“Oct_2020”)))

here sum variable in final will give you the sum of values of column Oct_2020

Nived N
Happy Automation


Already tried ur assign activity with note sum as system.double variable and works perfectly.


1 Like

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