Hi @IraWatt ,
Great question, in programming languages you would usually have a while-loop with the stop condition directly at the start. e.g. "while percentage <= 50".
In Alteryx, the stop condition can be the following:
Batch Macro: stops after looping over all records from the control parameter.
Iterative Macro: stops once the loop output is empty, OR the maximum number of iterations is reached.
To include a stop condition like 'percentage >= 50', the loop output needs to be empty once the condition is met.
An easy way to achieve this is to create a new field checking if the condition is true or false. You append this value to the dataset just before the loop output and use a filter checking if it is true or false. This results in an empty dataset if the condition is true and thus stops the loop.
You did this already in your macro. And you can look at other solutions to challenge 240 for further examples.
Best practice is always to make this clear in your workflow, so you and others understand it easily. For example using tool annotations and tool containers. See my solution to challenge 240 attached.
Please mark this as the solution if it answers your question, it will help others to find solutions quicker.
Solutions Engineer - Alteryx