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

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

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay