Hi,

I have data like this in a column in data table “Reload 1000 PKR to code 09”,“Reload 2000 PKR to code 09”

i want to take sum of 1st index from this column in datatable. i want 1000+2000=3000

what is the best possible way to do this

Hi @Tel43

Try dt.Asenumerable().sum(function (row) Convert.ToInt32(row(“column name”)))

Thanks

Ashwin.S

Hi

Try below code

dtFileter.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“columName”).ToString.Trim) )

i did this for rows having digits only but i need to split this string and get only the 1st index i.e. 1000 or 2000

For suppose, this is your row data: **Reload 1000 PKR to code 09**

Then use space as delimiter and split your String and get that value like below.

**yourString.Split(" ".TocharArray)(1)** - will give output as 1000

can i use this in place of Column in following code chunk?

dtFileter.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Column”).ToString.Trim) )

i want to do it in minimun steps instead of iterating through whole data table using for each loop

Try this:

**dtFileter.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Column”).ToString.Split(" ".TocharArray)(1).Trim) )**

hi Lakhman,

if possible can i share me snapshot of stemachine…by using above functionality…

Thanks in advance!

it Worked Thanks ALot

Cheers!

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