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 Condition Termina...
Power Automate
Unanswered

Loop Condition Termination

(0) ShareShare
ReportReport
Posted on by 5

Hello all, I am new here and currently learning Power Automate (mostly PAD) and learning a lot from the community.

 

I am currently stuck on a situation, please allow me to explain. I have an Excel spreadsheet which contains a list of locations in column A and the subsequent IP address for each of those locations in Column B. There may be multiple IP addresses per site, for example:

 

 

Location (A-Z)IP address

A

192.168.0.15

B

192.168.0.16

C

192.168.0.17

C

192.168.0.18

C

192.168.0.19

D

192.168.0.19

 

I would like to loop through each of those items in the list and terminate the loop once all of the required location IP addresses have been read. Each IP address will be added to a policy on a website for which I have built another flow for.

 

To test my theory, I created a test flow just for the purpose of testing my logic before I add this to my production flow. Warning: I am not an expert at loops or conditional logic, I am a novice who is really trying to learn them so please do call out if there is a learning opportunity as I may have complicated things with a lack of understanding.

 

2022-01-22 13_30_08-Window.png

The Practice2 variable contains the location I want to retrieve data for.

The Row variable determines the start row and will increment as part of the For each loop.

Once the Loop Condition is true and the Current Item = Practice2, my actions run and return the data for what is set in Practice2. This is what I want, however, I just can't figure out what I need to do next to terminate the loop once all of the required items in the list have been read.

 

I suspect some conditional logic is needed, I have tried a combination of If / Else but don't seem to be able to get it right.

 

Any help / advice would be welcome. Many thanks.

 

I have the same question (0)
  • Benny_1857 Profile Picture
    124 on at

    As you mentioned, you have a spreadsheet. The last row of this sheet is the number you need to termintated.

    So read the last free row of your sheet suppose it is 10. Set a start row number maybe 2. In your condition loop, if LastFreeRow > StartRow, run the loop and StartRow +1 each time. Once StartRow = 10, the condition loop end.

    https://docs.microsoft.com/zh-cn/learn/modules/pad-loops/

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Instead of conditional logic, you can set the start and stop of a regular loop. I do this by:

     

    Loop with % LoopIndex% starting at 2 (assuming you have a title row) ending at %FirstFreeRow - 1%, increment of 1

     

    Using this, LoopIndex always refers to your row number. 

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    As another point of conversation, your "Exit Loop" in the second loop is going to trigger every time, because you don't have any condition on the exit loop.  Meaning, that loop is worthless, because it's only going to go once every time.  Exit Loops should be in their own logic, like:

     

    Loop  starting at 1 ending at 9999 #note: this isn't how I do it, I'm just showing an example

        If Current Row > Last Row
            Exit Loop
        End (If) 

        'Do something for each row

    End (Loop)

  • AutoNate Profile Picture
    5 on at

    Thank you for your comments, I am going to review my flow today and incorporate your feedback.I really do appreciate you taking the time to help me out.

     

    I am not a developer and so learning the logic of actions has been challenging, but I am enjoying the process and will continue to work at it.

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 247 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 164 Super User 2026 Season 2

#3
trice602 Profile Picture

trice602 138 Super User 2026 Season 2

Last 30 days Overall leaderboard