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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Loop Condition on Date
Power Automate
Unanswered

Loop Condition on Date

(0) ShareShare
ReportReport
Posted on by 20

I have a For Loop and this date, if the next date in the for loop is August I want to hit the back arrow, if it is December I want to hit the forward arrow 3 times for example. I can create a column in Excel with the month of each date in number format. How can I implement this logic in the Loop Condition

 

FlashDota_0-1699039592825.png

 

I have the same question (0)
  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    I assume you already know how to Extract the text from that element displayed in your screenshot, so I'm continuing from there.

    This process will evaluate the 2 each time and only click the arrow once upon each valuation, then re-evaluate.  That way it's > or < 0, not extra lines of code trying to decipher if the 2 are part of the same year or not.

     

    Let's say that variable is %ElementText% and your next Loop date is a date variable set to %NextLoopDate%.

    Also %NextLoopDate% should be on the 1st of the month in this case, if not, convert %NextLoopDate% to Month/01/Year so it can be compared equally against %ElementDate%

     

    Label Click Arrows
        Convert Text to Datetime %ElementText% custom format MMMM yyyy to %ElementDate%

        If %NextLoopDate% > %ElementDate%

            'click right arrow

            GoTo Label Click Arrows  'this will basically loop us until %NextLoopDate% = %ElementDate%

        Else(IF) %NextLoopDate% < %ElementDate%

            'click left arrow

            GoTo Label Click Arrows  'this will basically loop us until %NextLoopDate% = %ElementDate%

        End(IF)

     

    Good luck

     

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

    I personally prefer not using labels, so my take on this would be more like this:

     

    Loop While %NextLoopDate% <> %ElementDate%

        Convert Text to Datetime %ElementText% custom format MMMM yyyy to %ElementDate%

        If %NextLoopDate% > %ElementDate%

            'click right arrow

        Else(IF) %NextLoopDate% < %ElementDate%

            'click left arrow

        End(IF)

    End (loop)

     

    But otherwise your solution does the trick!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard