Loop condition actions

Completed

Use the Loop Condition action when you need to repeat a block of actions until a certain condition is met. This approach lets flows repeat actions without prior knowledge of the number of repetitions required.

To demonstrate this functionality, you automate a flow that adds the employees’ expenses and stops when the budget is exceeded.

First, initialize the running budget at 0, set the starting Excel line to 2, and open the file:

Screenshot of the workspace example.

Next, add the loop condition, so that it ends when the budget exceeds 10,000:

Screenshot of the Loop condition action properties dialog.

Within the loop, the flow reads the amount, adds it to the running budget, and increases the index to move on to the next row:

Screenshot of the loop condition workspace example.

Exit loop

As developed, this loop only ends when the budget exceeds 10,000. However, if the sum of all expenses doesn't exceed the limit, the loop never ends. This condition is a good opportunity to examine the use of the Exit loop action. Before reading a cell’s contents, check if the Excel index exceeds the range of the data.

If all data is read and the limit isn't exceeded, assign the value False to the %Exceeded% variable and exit the loop, since there's no more data to read. Initialize the %Exceeded% variable to True in the beginning, since, in all other scenarios, the limit is exceeded:

Screenshot of the loop condition if workspace example.

Finally, add an If action to check the %Exceeded% variable, and print a message accordingly:

Screenshot of the completed loop condition if workspace example.