Do Until – Explained – Part 2

In my last Blog, I was explaining about Do Until where I explained the meaning of Limits- Count & Timeout.Lets explore it in Detail!

FACT CHECK 4: Well timeout has a precedence over Count. So if you keep the Count as 600 & Timeout as 1 min, the flow will stop after a min itself eventhough the Count might not have been completely achieved.

Thus, with Timeout property in the configuration, the loop will stop if Loop Condition is met OR Count number has reached OR Timeout duration is reached.

Let’s think of another scenario where if I put a Delay within the Do Until Loop which is more than the Timeout value, what will happen?

Lets try out!

So here I have taken a Boolean value as false and i am running the loop until it becomes true.I have put the Timeout as 1 min & introduced a Delay of 2 mins. Let us see what happens!?

As u can see the flow stopped running after 2 mins of Delay even though the Timeout was set for 1 min only.

Fact Check 5: Thus if I set the Delay action to take longer than Timeout value the loop will finish when Delay action time runs out.

Fact Check 6: We all know the validity of Flow Runs – it is just 30 Days i.e P30D. So no point in giving Timeout value more than this.

To know more about the Limits – follow Link

Lastly let’s see how to use Dates in Do Until as promised in my last blog. I have a bonus fact check here for you too.

Problem Scenario: We have 2 dates in hand and we have to count the no of days required to reach the 2nd date and also to print days from the very next day.

Solution: Lets just write a Power Automate – It has solution to all problems.* **

*Do not ask me for your Synchronous problems 😛
** I am just trying to explain a use case of Do Until, this problem can be solved in a lot of other oob manner.

Lets Start! Here i have taken 3 string variables to store dates and 1 array variable to print all dates.
Date 1- 07/07/2023
Date 2-07/11/2023 [these may come dynamically for dataverse]
Date 3-acts as a Temporary variable.

The condition is checking if Date 1 is less than Date2, and then only is proceeding.
PS: Always remember to compare both the dates in the same format by using the formulae formatDateTime(variables(‘Date1′),’MM/dd/yyyy’).

We are then copying the value of Date 1 temporarily into date 3.
Lets see what happens inside Do Until loop:

Here we are running the Do Until loop until the temporary date 3 reaches date 2 & with each iteration, we are increasing the date by a day.
TIP: You will see here i have used compose for adddays and then putting the result into date3. This is because i can’t self reference date 3 while assigning its own value, thus took the Compose route.

Lets run the flow:


The flow ran successfully with:


You might be wondering how did I get the count of days!?
Well we could have used an integer and increased it by 1 in every iteration BUT BUT BUT I used a property of Do Until loop.

Fact Check 7: So Do Until provides us a property of Current Iteration Index to find out the number of times it has looped.

Its expression is as follow: @{iterationIndexes(‘Do_until’)} and can be found here:

This starts from 0 and ends till the number of times it iterates. We could have used the same in numbering out items in my last blog.

So if you just have to count the number of days in b/w two dates, you may use this directly as it will give value 3[0-to-3] and the dates also you can print as you wish.
Hope it helps!


& the Power Quote of the days is:
“You’re braver than you believe, and stronger than you seem, and smarter than you think”

Author: powershalinee

Techno-Functional Consultant

Leave a comment