DEV Community

Frederik Van Lierde
Frederik Van Lierde

Posted on

1

For Next Loop in PowerAutomate (Easy)

We all know the 2 types of loops in PowerAutomate
1. Apply to Each:
This is the primary loop mechanism used in Power Automate for iterating over a collection of items, such as arrays.

When you have a list of items and you want to perform certain actions for each item individually, this is the loop you use. Power Automate takes care of the iteration, applying the actions you've defined to each item in the collection.

2. Do Until:
This loop performs actions repeatedly until a specified condition is met.

It's useful when you're not sure how many iterations you'll need, but you have a clear condition that determines when the loop should stop.

This allows for repeating actions based on dynamic conditions that might change with each iteration of the loop.

Available Loop Action in Power Automate

What about For Next Loops?

"For Next"-loops are essential when you need to execute a block of code a specific number of times, especially when you're working with indexes or counters.

They provide a precise control mechanism for iterating through a sequence or range of values.

How to create a For Next Loop in PowerAutomate?

The simple trick is to add as Input for an "Apply to Each" action a Range function

  1. Add a "Apply to Each" action to your flow PowerAutomate ForNext Loop
  2. As Input set "range(0,x)" where x is the number of loops you like to execute PowerAutomate ForNext Loop Range Function

The loop will execute X times.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay