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

Notifications

Announcements

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
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 740 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 342 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard