web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / What is the difference...
Power Automate
Answered

What is the difference between loops, Switch, Do Until, Apply to each and Expressions?

(0) ShareShare
ReportReport
Posted on by 932 Super User 2024 Season 1

I am new to Power Automate. I have come across the following in Microsoft Learn:

 

"

  • Loops – Runs an action until conditions are met to move to the next step of the flow

  • Switch – Identifies a single case to execute based on the evaluation of input

  • Do Until – Executes a block of actions until a specified condition evaluates to true

  • Apply to each – Executes a block of actions for each item in the input array

  • Expressions – underlying definition that describes the actual logic that runs in your flow that can be manually written"

https://learn.microsoft.com/en-us/training/modules/build-automated-solution/2-create-flow-template

 

1. I am a little confused between the differences between Loops and Do Until. The text above seems to indicate that Loops needs conditions to be met whereas Do Until only requires one condition to be met. Am I right?.

2. I have understood Switch to mean if it's X then do A, if it's Y then do B, if it's Z then do C. Similar to the Switch function in Excel and Power BI. 

 

3. Apply to each I imagine means for example for Data source 1 do X, for Data source 2 do Y and for Data source 3 do Z. All in one command. I think.

 

Am I right?. Any clarification will be greatly appreciated.

Categories:
I have the same question (0)
  • Verified answer
    Sundeep_Malik Profile Picture
    6,484 on at

    Hey @HamidBee 

     

    Yes everything seem right from above.

     

    Just to conclude everything and add some points.

     

    Use Apply to each when you have to go to each and every value in the array.

     

    Use Do until when you have to stop when the condition is satisfied. So for example you want to run the loop till you find a particular item in a SP List.

     

    So, now talking about switch it works like a switch in any other language. So mostly I can say, if else is used on two parameters, but if you have more than two, you can use a switch. For example, if you want to check name is equal to A. Then show the value A, and if it equal to B, then show B, and if the value is equal to C, the show C.

    So when ever you have more than two things, use switch instead of a condition.

     

    Now for the third point. I really didnt understand your point. Can you elaborate? You mean all the three in one apply to each or something???

     

     

    Edited(Including my second comment):

     

    Yes you are correct. Just for that do until you can try another thing if you want it include more conditions. 

     

    Inside that do until you can use a condition action. And if it gets true you can set up a flag variable there like we do in normal programming to break a loop when condition is satisfied. Plus you can write use 'or' and 'and' to have multiple conditions inside do until. 

    So the scope is not limited. 🙂

  • HamidBee Profile Picture
    932 Super User 2024 Season 1 on at

    For 'apply to each' I was trying to say that multiple actions happen at the same time.

     

    Also just to clarify, two conditions cannot be given for 'Do until?"? only one condition can be passed?. It sounds like if it's two conditions needed then a 'condition' should be used and no 'Do until'. 

  • Sundeep_Malik Profile Picture
    6,484 on at

    @HamidBee 

     

    Yes you are correct. Just for that do until you can try another thing if you want it include more conditions. 

     

    Inside that do until you can use a condition action. And if it gets true you can set up a flag variable there like we do in normal programming to break a loop when condition is satisfied. Plus you can write use 'or' and 'and' to have multiple conditions inside do until. 

    So the scope is not limited. 🙂

  • HamidBee Profile Picture
    932 Super User 2024 Season 1 on at

    Thank you I appreciate the help. I'm going to mark your first reply as an answer if you would like to edit it and include some of the things you mentioned in your second response. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard