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 / Random Letter Generato...
Power Apps
Unanswered

Random Letter Generator (Advanced)

(0) ShareShare
ReportReport
Posted on by 261

Hi Everyone.

 

I have 3 text labels that are set to randomly generate 1 letter each between A to F.

The user has the option to select a different letter which is also generated at random (on select) between A to F.

 

What I need is to figure out how to make sure that the letter generated will not be a duplicate of one of the other letters already on screen. 

 

Here is the code i have so far.

ClearCollect(Letters,Split("ABCDEF",""));ClearCollect(Letters1,Split("ABCDEF",""));ClearCollect(Letters2,Split("ABCDEF",""));ClearCollect(Letters3,Split("ABCDEF",""));UpdateContext({UpperCaseValue:""});Set(box1, false );Set(box2, false );Set(input3, false );Set(input2, false );Set(input1, false );Set(cover1, false );Set(cover2, false );Set(cover3, false );Set(reason1, false );Set(reason2, false );Set(reason3, false );Set(amendblock, false );Set(submitblock, false );Set(randletter,First(Shuffle(Letters)).Result);Set(randletter1,First(Shuffle(Filter(Letters,Result<>randletter))).Result);Set(randletter2,First(Shuffle(Filter(Letters,Result<>randletter,Result<>randletter1))).Result);Set(randletter3,First(Shuffle(Letters)).Result)

20190916_164717.jpg

 

Any ideas on this would be great.

 

Thanks. 

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    There is a function called shuffle which should do the job you're after wonderfully.

     

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-shuffle

     

    Basically to get three numbers create a table of letters and store in a collection, here called colAlphabet and then you can clearcollect like this ClearCollect(colThreeLetters,FirstN(Shuffle(colAlphabet),3))

     

    The first N will return the first three letters from the shuffle which will ensure that none are duplicated.

  • Courtney Profile Picture
    261 on at
    Is it possible to use the (If) formula to exclude repeating letters which are already visible on other labels?

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard