Excel - Sum of column

Hi,

I’m trying to get the sum of a column and I used the query dt_Input.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Total”).ToString.Trim)).ToString

I get “Input string was not in a correct format.” error. Can anyone help me out?
image

Thanks

Fine
do we have any - symbol or any space between numbers or any comma between numbers
kindly validate that once pls
Cheers @VanithaRajakumar

1 Like

Hi… I have attached the input screenshot above. Its the same. There is no space or character in the numbers

Hello @VanithaRajakumar
use this code
DT.AsEnumerable.Sum(Function(r) If(IsNumeric(r("ColumnName").ToString.Trim), CDbl(r("ColumnName").ToString.Trim), 0) )

3 Likes

@vickydas. Thanks a lot. It worked :slight_smile:

Hi ,
To sum the DataTable column , you use this activity.

Regards
Balamurugan.S

1 Like

Thank you all for the quick response…!! Vickydas’s solution worked for me.

1 Like

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