In traditional coding paradigms, for loops are a staple for iterating over a collection of items. When the desired condition is met or the task is complete, one can simply exit the loop using a break command. However, in Power Automate, this direct approach is not available. For each loop in Power Automate does not support a break or terminate command directly within its flow.

To effectively manage loops in Power Automate, one must utilize variables to control the flow. This involves setting up a variable prior to entering the loop and then, within each iteration, checking the variable’s value to determine whether to continue or exit the loop. This method requires careful planning and setup but allows for controlled execution within Power Automate’s framework.

In my case I needed to collect data from multiple rows and when I found what I needed, I could stop the loop. But I cannot, therefore I collected the needed data into array variables.

  1. Create variables for collecting the data needed later in Power Automate for processing
  2. Get needed rows from Dataverse
  3. Add each loop for the rows from Dataverse
  4. Create a Condition where you first check the value condition like normally in the loop
  5. Then add second row when you figure out when the needed data is collected, where normally you would break the loop
  6. In the Yes clause append the data into your variables

Why not use Do until loop? Yes basically you could use that and set the limitation in the Do until clause. But when you cannot combine going trough a collection without index. There might be change to build a array with index but then there is so much code in low code solution that normal low code person would not understand the basic. It is better to collect to another variable and try to use out-of-the-box actions for getting the job done.