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 last Index Problem
Power Automate
Answered

Loop last Index Problem

(0) ShareShare
ReportReport
Posted on by 55

Hello.

I set it to increase by 1 in loop 1-3 and always see that the increase value is added to the last value once the loop is over.
Is this normal?

In the above example, shouldn't the last value be loop index 3?
But it goes out of loop and becomes loop index 4.

I've tested it several times, but I think it's a bug..
No one questions it.

I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @song_coach 

     

    could you show how you designed the loop in your case ?

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • song_coach Profile Picture
    55 on at

    @Nived_Nambiar 

    song_coach_1-1695817491960.png

    song_coach_2-1695817594977.png

    it's increased by 2 in the loop range of 0 to 4
    The loopindex values ( 0,2,4) 

     

    I think it should end with a value of 4 in the loop range
    However, the loop is terminated and the loop index value is added once. (loopindex 6)

     

    I don't understand if the loopindex value is added even though the loop is terminated.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    This is a common thing in PAD. It does happen like this, because the starting Loop action increments the index, and not the End action. What this means is that on the last iteration, the starting action does run, but the actions inside the loop are not.

    So, you would not get an extra iteration of the loop, but you will have a loop index larger than the end range after the loop has ended.

     

    If you care about the index after the loop ends, use a separate variable and do Increase variable at the end of your loop.

    -------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Agnius 

     

    Thank you for sharing this information 🙂

     

    was not aware of that 

     

     

  • song_coach Profile Picture
    55 on at

    @Agnius 

    How is this such a common occurrence? I haven't seen this handled in any program.

    It's problematic that, upon completion, instead of exiting the loop, it increases the index by going through one more iteration.

    I don't comprehend it programmatically, and I question why PAD is maintaining this method.

    Moreover, when dealing with data processing, I often have to use many loop indices, and this fundamental issue leads to additional coding.

    I believe that this issue should be addressed and corrected.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If you believe it should be fixed, feel free to report it as a bug to MS Support. I am not employed by MS, so I cannot do anything about it. I've just shared what I know of the issue and explained why this happens and how to work around it. That's about as much as I can do here.

     

    If you do report it to MS and IF (which is a much bigger if) they agree to fix it, it will still take at least a couple of months before a fix like that gets released to general availability. So, if you actually need to use this in a project any time sooner, I suggest you use the workaround I proposed until then.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • song_coach Profile Picture
    55 on at

    @Agnius 

    I don't expect a quick fix either.

    It seemed like a basic issue that should have been fixed earlier, but I wrote this in case someone encounters a similar problem since there were no questions about it in the community.

    If it's not too much trouble, do you happen to know how to report bugs to Microsoft support? Can anyone report a bug?

    Thank you for always providing answers.

    Best Ragards.

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    It's like a Loop While command:

    i = 0

    Loop While i <= 4 (you don't see this)

        'code

        i = i + 2 (you don't see this)

    End Loop

     

    I would just declare the %LoopInterval% as a variable and after End Loop and put
    %LoopIndex% = %LoopIndex - LoopInterval%
    After End (Loop)

     

    This will bring it back down.  I understand it's odd behavior but this will give you a fix today, rather than waiting for MS.  Good luck!

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If you have a paid subscription for Power Automate, you can report a bug via the cloud portal by navigating to https://make.powerautomate.com/support

     

    Alternatively, you can do it via the Feedback hub by clicking Help > Feedback in your PAD console:

    Agnius_0-1696491848368.png

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • song_coach Profile Picture
    55 on at

    @MichaelAnnis 

    Hello.

    Thank you for your response.

    In case the loop index rule returns to normal later, I have added an if statement to break when the loop index value is the last one.

    I'm just a bit disappointed that we have to add this extra coding for such a basic issue every time.

    Best Regards.

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 167

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard