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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to terminate a App...
Power Automate
Unanswered

How to terminate a Apply to Each loop?

(2) ShareShare
ReportReport
Posted on by 3,347

I have to process the name of every folder in a List Files in Folder action.  There will only be one result in this activity.  Thus, when I get a positive to my condition, I need to terminate the loop.  Is there a way to do this?   I would love to be able to use Concurrent, then it would be super fast, but concurrent messes with the results of the condition, so thats a no-go.  Thoughts?

Categories:
  • Mira Ghaly Profile Picture
    11,415 Moderator on at

    @martinav

    Please check the below article it uses an approach to break out of an apply to each loop. 

    https://www.c-sharpcorner.com/article/break-loop-apply-to-each-if-a-condition-fails-in-ms-flow/

     

    Hope this helps! 

  • martinav Profile Picture
    3,347 on at

    @Mira_Ghaly ,

     

    Well...  it fundamentally does work.  However, the point of it is to save time.  It still takes 32s to run through all 71 items of the loop.  It finishes at item 15, but the remainder where the outside loop is 'false' still takes the same amount of time to execute.  So, there is not much point in it.  

     

    This flow is being initiated from a powerapp.  So, I need it to run very fast.  I will have to look at a different way to do this.

  • craigyappert Profile Picture
    57 on at

    sorry .. this is currently a limitation and one of the reasons why many people counsel to steer away from For-Each loops if possible.

     

    But without seeing your actual flow I don't see how you couldn't speed this up ... I'm not sure how you are getting filenames but if can pull an array object back Select the Array just to the filename object. then the loop should be really fast.... even with the extra loops.

     

    It's been a UserVoice request for a while now.

     

     

  • AndreyBear Profile Picture
    42 on at
  • AbdulWahab Profile Picture
    517 on at

    Hi @martinav ,

     

    I think you can use do-until by using a similar approach. I am in a similar situation after reading the tread I analysed I can solve my problem using do-until. It will help you also.

     

    If I have answered your question, please mark your post as Solved.

     

    If you like my response, please give it a Thumbs Up.

     

    Let me know if I can provide you with more details.

     

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: https://www.linkedin.com/in/abdul-wahab-a5b8b011a/

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 289

#2
11manish Profile Picture

11manish 282 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 119

Last 30 days Overall leaderboard