How to add values when col length is not known?

I’m having a data table like this

Pay Comp1. Comp2
1000. 500 500

I want

I want to minus comp 1 and comp 2 from net


Pay Comp1. Comp2
0. 500 500

The no of comp (cols) might keep varying

How to do this?

Hope these steps would help you resolve this
—Use a excel application scope and uminsee the scope use read range activity and get the output with a variable output of type datatable named dt
—now use a FOR EACH ROW activity and pass dt as input
—Inside the loop use a WHILE LOOP activity like this
int_sum = int_sum + Cint(row(count).ToString)

Where int_sum is sum of all columns except pay
So count is a vary of type int32 with default value as 1 defined in the variable panel

Next to this use a assign activity like this
count = count + 1

—now next to this While loop use a assign activity like like this
row(0) = int_sum - cint(row(0).ToString

Cheers @cybzom

1 Like

What should I give in while condition?

1 Like

The condition is
count < dt.Columns.Count

Cheers @cybzom

Hello @cybzom

You can do this by the above method suggested by @Palaniyappan

Or else you can do the same thing easily using LinQ and using a single assign activity

Check this Workflow and let me know about it

Column Subtraction.xaml (8.6 KB)