Trying to Add more than 2 variables in Logic App Cosmos DB

Viewed 89

Requirement in Logic App : Need to add 4 variables into a single variable.

I am using the expression Add(Variable1, variable2, variable3, variable4)

But it throws the below error. Error

Is there any other way to add 4 variables(int).

Expression Add

2 Answers

Compound them, i.e. use this concept ...

add(add(add(variables('Number 1'), variables('Number 2')), variables('Number 3')), variables('Number 4'))

This test flow ...

Flow

... gives me this result when I add them using that compound approach ...

Result

However, if the amount of numbers you're adding is dynamic, you may need to loop.

Since Add()'s synatx is Add(summand1,summand2), you can do something like below

Add(variables('Variable1'),Add(variables('Variable2'),Add(variables('Variable3'),variables('Variable4'))))

Here is my logic app

enter image description here

RESULT:

enter image description here

Related