The Power Apps RANDBETWEEN function generates a random whole number within a specific range. For example, we could ask for a random number between 1 and 10.
|Bottom||Yes||A whole number that is the lowest number in the range|
|Top||Yes||A whole number that is the highest number in the range|
Suppose we want to generate a random number between 1 and 10. We could write the following Power Apps RANDBETWEEN function.
The result is a random number between 1 and 10. Each time the function is used it returns a different result. The 1st time I call the RANDBETWEEN function the result could be 3. Then the 2nd time I use RANDBETWEEN the result could be 7. The 3rd time I use the RANDBETWEEN function the result could be 1.
A challenge with the RANDBETWEEN function is the result always changes. If we wanted to keep the number generated by RANDBETWEEN for later we could store the result inside a variable.
Set(varRandomNumber, RandBetween(1, 10))
Did You Enjoy This Article? 😺
Subscribe to get new Power Apps articles sent to your inbox each week for FREE
Love the formula, use it a lot to create Random demo data and used it to place the next target in my snake-game. Nice AddOn for fun Apps.
And you can choose a random item from a collection without Shuffle() now:
Index(Collection, RandBetween(1, CountRows(Collection))