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 / Loop throws index out ...
Power Automate
Answered

Loop throws index out of range.

(0) ShareShare
ReportReport
Posted on by 8

So I'm trying to have the name of all folder in a folder, then remove the file path of the name so I can get the name alone. It gives me an index error, but it still works great so it doesn't really matter there. The thing is, this was one part of a bigger flow. And when this error get thrown, it stops the rest of the flow, which is a problem there.

Xiarno_0-1644360872980.png

Xiarno_1-1644360883209.png

How to fix this if possible please ?

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    Loop 0 to %Folders.Count - 1%

     

    Since the list has a 0 based index, there is 1 less index than number of rows.  Count returns the number of rows, so you have to subtract 1 to loop on indexes.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Dunno, to me it seems like loops should be < not <= when doing the Count or Length comparison.

     

    Seems strange that this stayed the same since WinAutomation transition.

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
11manish Profile Picture

11manish 307 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 289

#3
Henil Profile Picture

Henil 127

Last 30 days Overall leaderboard