Hi,
Is it possible to generate a non-repeating random numbers?
I have this syntax:
ClearCollect( RandomNumbers, ForAll( [ 1, 2, 3, 4, 5,6,7,8,9,10 ], RoundDown(
txtRandStart.Text + Rand() * (txtRandEnd.Text + 1 - txtRandStart.Text), 0 )))
And when I generate the numbers, there's a repeating numbers.
Any help is appreciated! ๐
Regards,
May
Hi @mdevaney ,
Thank you for your reply and the link that you provided.
I added Shuffle to get random number ๐
FirstN(
Shuffle(Sequence(
Value(txtRandEnd.Text)-Value(txtRandStart.Text)+1,
Value(txtRandStart.Text)
)), 10
)
@mayarnaldo
You can do this by using the SEQUENCE function to generate the list of numbers you want to pick randomly from.
Use this code to get the 1st number in the random set.
First(
Shuffle(
Sequence(
Value(txtRandEnd.Text)-Value(txtRandStart.Text)+1,
Value(txtRandStart.Text)
)
)
).Value
Use this code to get the first 10 numbers in the random set
FirstN(
Shuffle(
Sequence(
Value(txtRandEnd.Text)-Value(txtRandStart.Text)+1,
Value(txtRandStart.Text)
), 10
)
)
If you want to learn more cool ways of using the SEQUENCE function check out this article
https://matthewdevaney.com/sequence-function-in-power-apps/
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473