Loop is a function that repeats the same process.
- 1. Loop Actions
- 2. Loop control Actions
- 3. How to deal with infinite loops
- 4. For those who want to learn Power Automate Desktop effectively
- 5. Links
- 5.1. Power Automate Desktop Introduction.
- 5.2. Examples of Use
- 5.2.1. Obtain the number, total, average, maximum, and minimum of the numbers in the list.
- 5.2.2. Send newsletter. Email one line at a time from an Excel book.
- 5.2.3. How to record the contents of an incoming email line by line in an Excel book.
- 5.2.4. How to convert URL parameters (GET parameters) into Data table.
- 5.2.5. How to rank a list of numbers.
- 5.2.6. How to get the deviation.
- 5.2.7. How to get the least common multiple and greatest common divisor.
- 5.2.8. How to get the median.
- 5.2.9. How to get the standard deviation.
- 5.2.10. How to get the mode.
- 5.2.11. Create a table of contents for sheet names in an Excel book.
- 5.2.12. Delete rows of Excel with specific conditions.
- 5.2.13. How to delete multiple rows/columns in Excel.
- 5.2.14. Automated basic text file operations
- 5.2.15. Specify date range to retrieve mail.
- 5.2.16. How to save the contents of a PDF to a text file.
- 5.2.17. How to read an Excel file and process it line by line in a loop.
The loop has three actions, which can be used depending on the situation.
|Loop||Repeat a specified number of times.|
|Loop condition||Repeat while specified conditions are met.|
|For each||Repeat all rows of the List or Data table.|
Loop Action repeats a specified number of times.
To use it, drag a Loop Action onto the Workspace.
Repeat 10 times with Start From set to 1, End to set to 10, and Increment by set to 1.
The Variables produceced (LoopIndex by default) is set to the number of loops.
In the below, the Message box from 1 (Start From) to 10 (End to) are displayed 10 times.
Repeat 10 times, even if Start From is 10, End to is 1, and Increment by is -1.
In this case, the LoopIndex counts down from 10.
This loop is used for count up/down, otherwise the other loops are used.
Loop condition Action
The Loop Condition Action repeats while the specified condition is met.
To use them, drag a "loop condition" onto the Workspace.
Set a condition similar to If Action. Repeat as long as this condition is True.
For each Action
The Store into (CurrentItem by default) is set to the item at that time.
In the example below, iteration is performed on the list [10,20,30,40,50], and 10,20,30,40,50 will appear in the message box in the display. (5 iterations)
Loop control Actions
There are two actions that can be placed within a loop action to change the Flow of the loop.
|Next loop||Skip subsequent actions and move on to the next loop.(Continue)|
|Exit loop||The subsequent action is skipped and the loop is terminated.(Break)|
Basically, it is used when some condition (If or Switch) is satisfied.
For the sake of comparison, we have used a simple example where the condition is LoopIndex=3, but in practice, more complex conditions, such as some kind of error, will be used.
Skip subsequent actions and move on to the next loop.(Continue)
To use it, drag the Next loop Action onto the workspace.
The Flow below will display a message box 10 times if there is no Next loop Action, but it will skip only when the LoopIndex is 3, due to the Next loop Action.
The message box will appear 10 times if there is no Next loop Action, but it will be skipped only when the LoopIndex is 3. (Displayed 9 times)
The subsequent action is skipped and the loop is terminated.(Break)
To use, drag Exit Loop Action under Loop.
In the Flow below, the message box would appear 10 times without Exit Loop Action, but the Exit Loop Action displays the message box twice and then exits the loop. The Exit Loop Action displays the message box twice and then terminates the loop.
One way to use the Loop condition Action as a never-ending condition, such as 1=1, and Exit Loop Action as an end condition is to use Exit Loop Action as an end condition.
How to deal with infinite loops
If the loop does not end, the Stop button forces the Flow to stop.
For those who want to learn Power Automate Desktop effectively
The information on this site is now available in an easy-to-read e-book format.
Or Kindle Unlimited (unlimited reading).
You willl discover how to about basic operations.
By the end of this book, you will be equipped with the knowledge you need to use Power Automate Desktop to streamline your workflow.