web
Youโ€™re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : h6BpcqRz5zkO7Ev3ivkSft
Power Apps - Building Power Apps
Answered

Non-repeating random numbers

Like (0) ShareShare
ReportReport
Posted on 9 Dec 2020 13:12:46 by 92

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.

2020-12-09_14-03-55.png2020-12-09_14-04-06.png

 

 

Any help is appreciated! ๐Ÿ™‚

 

Regards,

May

Categories:
  • Verified answer
    mayarnaldo Profile Picture
    92 on 09 Dec 2020 at 15:13:19
    Re: Non-repeating random numbers

    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
    )

     

  • Verified answer
    mdevaney Profile Picture
    29,987 Moderator on 09 Dec 2020 at 14:51:20
    Re: Non-repeating random numbers

    @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."

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Telen Wang โ€“ Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Communityโ€ฆ

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful forโ€ฆ

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473