 # How to get the value for each row

Hi All
is their a way to get the total of a row as shown below
way to get the total as a Var
Thank you

2. Drop ‘For Each Row’ activity and provide datatable variable.
3. Inside ‘For Each Row’ assign the int variable and give value like this, `Convert.ToInt32(row(YourColumnName).ToString)+Convert.ToInt32(row(YourColumnName).ToString)+Convert.ToInt32(row(YourColumnName).ToString)+Convert.ToInt32(row(YourColumnName).ToString)`

Feel free to reach us at any time if you have doubts. Thanks.

Happy Automation

1 Like

@Tharusha_Fernando
give a try on following

prepare a result datatable e.g. dtResult = dtOrigVar.Clone

use an assign activity:
left side: dtResult
right side:

``````(From d in dtOrigVar.AsEnumerable
Let t = {"car loan","housing loan","food", "transport"}.Sum(Function (x) Convert.ToInt32("0" & d(x).toString.Trim))
Let ra = d.ItemArray.Append(t).toArray
4 Likes

Thank for commenting
i have around 30 Column so i cannot write all the column name is their any way to mention the Range of the columns that i want to add

This is the look of my DataTable
B4:AE15

lets assume you want to sum up all columns:
Let t = d.ItemArray.Sum(Function (x) Convert.ToInt32(“0” & x.toString.Trim))

Lets assume you want to sum up not all columns but all with the name 1,2,3…30

``````Let t = Enumerable.Range(1,30).Sum(Function (x) Convert.ToInt32("0" & d(x.toString).toString.Trim))
``````
1 Like

Hi @ppr
What does d Stands for

it is like a parameter and represents the current item on which is worked

1 Like

it worked thank you

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