Picture: One Infinite Loop, Ignacio Sanz, CC BY-SA 2.0, via Wikimedia Commons and Flickr
The Problem: Power Apps only has ForAll
Loops
When I was creating a demo Power App to fetch and display Dad Jokes, one of the challenges I faced was to fit the joke text inside a speech bubble graphic. The speech bubble was expandable, but only within limits, so I needed to keep fetching jokes and checking the length of their text until I found one short enough to fit inside the bubble design.
However, looping in Power Apps turned out to be tricky. Unbelievably, I discovered there is only one kind of loop in Power Apps: ForAll
, which is used for looping over tables and collections. Power Apps really doesn’t have any other kind of loops, or even GoTos in the coding it makes available.
Making a While Loop in Power Apps
However, after much research, trial and error, I found a way to do this with just the loop (More Dad jokes) button and a hidden toggle: