Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
SonTaki
Contributor
Contributor

Loop until condition = true

Hello,

How can I create a loop that will run until the condition is true. Something like:

If condition equals true -> exit loop, else check again

Best I could think of is using the Loop block with list variable as input, so I can run the loop e.g. 20 times. However, it might be that 500 runs are needed. That is why I need the loop to run until the condition is met.

Hope someone can help. Thanks!

1 Solution

Accepted Solutions
PietMichielRappelet
Former Employee
Former Employee

Hi SonTaki

Option1: I've used a simple excel and concatenate function but I'm sure many basic script tools can generate this :). 
Option2: I've quickly recreated a similar automation, see attached

last question: Loop/if is not the same as while. We loop over a list, meaning you have a fixed set of runs. Also, having an if condition returning always true does not add value in a flow, you can just skip this and continue your flow.

Hope this helps. 

View solution in original post

3 Replies
PietMichielRappelet
Former Employee
Former Employee

Hi Sontaki

Thanks for your request. Unfortunately, we do not have native support for while loops or to loop x times, where is in an input parameter. I would suggest using our ideation pages to post this as a feature request: https://community.qlik.com/t5/Suggest-an-Idea/idb-p/qlik-ideas

You are suggesting the most used workaround: looping over a list of x items, and exiting when a condition is met.

PietMichielRappelet_0-1641549606571.png

another, less used method, is using labels: 

PietMichielRappelet_1-1641549643625.png

Hope this helps, 

Kind regards, 

SonTaki
Contributor
Contributor
Author

Thank you very much, Piet! I still have some questions:

Option 1: is there a way to generate a list on the fly, e.g. 1 to 10000, without typing each value individually.

Option 2: this looks interesting, would you be able to post the json file please?

Last question: Instead of the Loop block (as you have it in option 1) I tried with a Condition block "If 1 does not equal 2" which theoretically should run indefinitely until the condition within the loop is met :D. However, the entire automation fails. Do you know why?

Thank you!

PietMichielRappelet
Former Employee
Former Employee

Hi SonTaki

Option1: I've used a simple excel and concatenate function but I'm sure many basic script tools can generate this :). 
Option2: I've quickly recreated a similar automation, see attached

last question: Loop/if is not the same as while. We loop over a list, meaning you have a fixed set of runs. Also, having an if condition returning always true does not add value in a flow, you can just skip this and continue your flow.

Hope this helps.