Automation is not just about triggering actions — it’s about handling repetitive tasks with ease. In Power Automate, this is achieved through loops. Whether you’re processing emails, saving files, or updating multiple records, loops help you repeat actions without manual effort.
In this blog, we’ll dive deep into Apply to Each and Do Until — the two key looping mechanisms in Power Automate.
🔹 What Are Loops in Power Automate?
Loops are structures that allow your flow to repeat actions until all items are processed or a condition is met. Think of them as the “repeat button” for automation.
🔹 Apply to Each – Process Every Item in a Collection
📌 What It Does:
The Apply to Each loop is used when your flow deals with a list or collection of items (like multiple emails, files, or rows in Excel).
📌 Example Scenario: Save All Email Attachments to OneDrive
- Trigger: When a new email arrives (Outlook connector).
- Action: Get attachments.
- Apply to Each: Loop through all attachments.
- Inside Loop: Save each attachment to OneDrive.
👉 Result: Every attachment from every incoming email gets automatically saved — without missing any.
🔹 Do Until – Repeat Until a Condition is Met
📌 What It Does:
The Do Until loop keeps running actions until a specific condition becomes true. It’s useful when you want more control over when to stop repeating.
📌 Example Scenario: Retry Until File Upload Succeeds
- Trigger: When a file is added to OneDrive.
- Action: Try uploading the file to SharePoint.
- Do Until: Repeat the upload until the status = “Success”.
👉 Result: Even if the upload fails initially, the flow will retry until it’s successful.
🔹 Differences Between Apply to Each & Do Until
Feature | Apply to Each | Do Until |
---|---|---|
Purpose | Process every item in a collection | Repeat until a condition is true |
Use Case | Emails, attachments, rows, files | Retrying uploads, waiting for approvals |
Execution | Runs for each item once | Runs until condition is satisfied |
Control | Fixed (based on collection size) | Flexible (stop when condition met) |
🔹 Best Practices for Using Loops
✅ Use concurrent controls for Apply to Each to improve speed (parallel execution).
✅ Set a timeout and maximum iterations for Do Until to avoid infinite loops.
✅ Keep actions inside loops optimized — unnecessary steps can slow down flows.
✅ Test loops with sample data before applying to large datasets.
🔹 Real-Life Example Flow – “Save Email Attachments with Apply to Each”
🔹 Conclusion
Loops in Power Automate are like your personal assistants that never get tired of repeating tasks.
- Use Apply to Each when working with lists or collections.
- Use Do Until when you need more control and conditions to stop execution.
Once you master loops, your automations will become smarter, faster, and far more reliable. 🚀