Make an addition of the values of a dynamic variable

Hi! Good night
This is probably a very simple thing to do but I am new at programming and new in Uipath.
I need to perform the sum of the values of a variable that changes continuously since it is in a for each.
I can’t understand how to get the value and add it to the next value that that variable stores.
For example, the first execution of the for each will save the value of 15 in my aux variable, the next time it will be 5, and the next 10.
How do I make this variable that changes constantly return the sum of these values that it obtains with the executions?
Thanks for your attention.

Hi @Mark_Bonnet

Welcome to the UiPath Community.

Try this-

Before for loop

Sum = 0

Inside for loop

Sum =Sum + aux_variable

1 Like

Hi there,

Your question is a bit general and it really does depends where your source data is coming from. In your case, i suppose you would store your value in an array type variable. Next, you loop through the variable using For Each and execute them.

That’s what i would do.

aux = {15, 5, 10}
Foreach
value in aux
value +
sum
End foreach

Thank you very much! It works.

1 Like

Thanks for your help!

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