web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Non-repeating random n...
Power Apps
Answered

Non-repeating random numbers

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

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

  • Verified answer
    mayarnaldo Profile Picture
    92 on at

    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
    )

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 493 Most Valuable Professional

#2
11manish Profile Picture

11manish 479

#3
Haque Profile Picture

Haque 328

Last 30 days Overall leaderboard