How can I use a while loop inside a while loop?

I have a workflow where there are 2 variables i & j. I am declaring i & j as strings as follows:
i = {“January”, “February”} and j = {“2018”, “2019”}

Now I want to use 2 while loops where the output must display as below:
January 2018
February 2018
January 2019 and February 2019

How can I achieve this task?

Hi, I understand that i and j would be in fact arrays of strings. How about using For Each instead?

That’s a great idea. Thanks! it helped.

Cool! :slight_smile:


Can you please explain me how to manually increment the values present inside an array of strings.

Like lets say i = {“January”, “February”, “March”}
if (condition is met take in January)
else ( take February)
and proceed forward with the loop.

Hi @vivek_Chowdary,

I am unsure if I am getting the condition right - you mean: for each year if some condition is met, then “January +year”, else make a “for each month” loop to get “February + year”, “March + year” etc.? Do you want to simply exclude January from the array placed under “i”?


I don’t want to remove it completely, but if a condition is true I want to execute it. Else I want to print from the next element in the array.

I would then add double if in your “for each year” section of the automation, where “result” here is just a variable created to check a condition. Is the output something you are looking for? If the condition is met here, the output is “January 2018, January 2019”. Of course, I have also added “March” to the array scope of “i”.

while.xaml (9.6 KB)


In the example above I need to prove that, if (result = “example”)
then(print from January to March)
else(print from February to March)

How about now? You just need to place “For Each month” like you had it the first time within “then” instead of that “Write line” activity. The output is shown for the case when “result” was entered as “example”.
while.xaml (10.7 KB)


I also have used a similar kind of approach. But what’s happening is if the condition is met it’s executing. But if its not met then the robot is not going into the for loop and the execution is being stopped.

Have you put “For Each” loop both in “Then” and “Else” of your “If”? Can you share a screenshot of this part of your workflow?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.