How to break "Apply To Each" Loop using Variables in Power Automate

In this article, I’m going to explain how to break the Apply to each loop in power automation by using a variable if the condition is not correct.

Create a flow with a loop Apply to Each

Initialize one variable before the loop with the value "True".

How to break "Apply To Each" loop using variables in power automate

Inside the loop, add one condition with your other conditions as "Variable 1" is equal to "True" so that our loop will begin.

How to break "Apply To Each" loop using variables in power automate

Now to stop the flow if the condition fails, we have to use action as a set variable.

How to break "Apply To Each" loop using variables in power automate

As per the above screenshot, if we want to continue our loop, then set the variable as "True". Else, make it "False" if you want to break the loop.

Note. There is one direct action available to close the flow i.e., Terminate, but we can’t use that function inside the loop, so the above method may work in some of the scenarios.


Similar Articles