Skip to main content

Notifications

Community site session details
Power Automate - Building Flows
Answered

For Each vs Apply to Each

Like (0) ShareShare
ReportReport
Posted on 11 Jun 2024 10:59:09 by 8

I'm trying to use a loop in my flow, which will apply multiple actions to each item in an array.  I have read that an "Apply to Each" loop can only apply one action to each item, and indeed if I add multiple actions to the loop it errors out with "The input parameter(s) of operation 'Apply_to_each' contains invalid expression(s). Fix invalid expression(s) for the input parameter(s) of operation 'Apply_to_each'".  This error doesn't appear and the flow runs successfully if I only apply one action.  The second action in the loop does not contain an error, it's a simple compose.

 

So I think I need a "For Each" loop but that doesn't appear anywhere in the list of actions.  My only loop options in Control are "Apply to Each" or "Do Until".  However I know that "For each" still exists, because in one of my other flows it kept appearing automatically in mysterious circumstances.

 

I've searched until I'm blue in the face but can't find a solution, can anyone help?  Thanks.

 

EDIT: It turns out I did have an error in the second action but that reports an error in the loop rather than the action itself, which is why I was confused, so now I can get two actions in the loop.  However, I still don't understand if "For Each" is a valid action - I have checked and I have another flow containing "For Each", which I created yesterday, but I'm not clear on the difference with "Apply to Each" and how to insert "For Each".  Can anyone clarify whether "For Each" is still a supported action, what the difference is with "Apply to Each" and how to insert it?

  • shalem120kjh Profile Picture
    80 on 24 Jun 2024 at 13:23:23
    Re: For Each vs Apply to Each

    Today I saw the "For Each" action appeared in my flow, and I was also confused since I didn't know it exist. Reading this post and @v-bofeng-msft answer - it became clear. Power Automate added the "Apply to each" action for me (and for you as well), as it always does when you are using an array as an input to another action, without realizing that an "Apply to each" is necessary. The difference is with the new designer it is now added with the name "For each" instead of with "Apply to each". But it is the same action. 

  • cambridgepic Profile Picture
    8 on 12 Jun 2024 at 14:35:42
    Re: For Each vs Apply to Each

    Got it, that makes complete sense.  What doesn't make sense is that I didn't change the name, and nor did I insert it, it somehow appeared automatically.  It could be that there's a template but I didn't create any templates and I'm the only user in our organisation that has used Power Automate.  However, I can survive without knowing the answer to that mystery now I know the answer to my original question.  Thanks.

  • v-bofeng-msft Profile Picture
    on 12 Jun 2024 at 09:39:15
    Re: For Each vs Apply to Each

    Hi @cambridgepic ,

     

    Once an action is added to the flow, its name can be changed freely. The action in your screenshot is 'Apply to each.' The reason it appears as 'For Each' could be that you used a template, someone renamed it, or there might be another reason that I am unaware of.

     

    Best Regards,

    Bof

  • cambridgepic Profile Picture
    8 on 12 Jun 2024 at 08:46:13
    Re: For Each vs Apply to Each

    There is, it's possible it is deprecated but see this screenshot of one of my flows this morning (created two days ago).Screenshot 2024-06-12 094059.png

  • Verified answer
    v-bofeng-msft Profile Picture
    on 12 Jun 2024 at 01:38:27
    Re: For Each vs Apply to Each

    Hi @cambridgepic ,

     

    I'm  afraid there is no such an action named 'For each'. From a functional perspective, I believe you can regard 'Apply to each' as equivalent to 'For each'.

     

    Best Regards,

    Bof

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,079 Most Valuable Professional

Leaderboard
Loading started
Loading started
Loading complete