How to sumup String values in a datatable



Hi Guys,

I am facing a trouble that:1

  1. String values can’t be summarized due to datatype issues;
  2. If I did convert the column of String values into int32, then I couldn’t sumup the numeric values unfortunately.

So can anyone help take a look at my flowchart, and tell me where I made mistakes?

Thanks a lot!
sample 1

datatble col sumup Phil.xaml (12.1 KB)


Hello there,
You do have an option while building datatable ,it would’ve been easier if you change your data type to int while building.


However if its already in string type you could try this out:
dtAllRows.AsEnumerable().Sum(x =>Convert.ToInt32(x[“Cost”]))

For the reference:
datatble col sumup Phil.xaml (16.9 KB)


Great Thanks !! @ddpadil


Hi @Phil_Wu,
A single activity will do the convert the type and do the sump. Check it below.


How to sum all values in a column of an excel/Datatable?

I tried below method, also with your attached xmal there is error , how did u solve this.
can you please to resolve

**dtAllRows.AsEnumerable().Sum(x =>Convert.ToInt32(x[“Cost”]))