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 Name picker bas...
Power Apps
Unanswered

Random Name picker based on conditions

(0) ShareShare
ReportReport
Posted on by 153

I want to randomly select names from my sharepoint list based off position, I am currently using:

 

ClearCollect(shuffledNames,Shuffle('list name'))

 

to shuffle names within my gallery. How can I add a condition to only select names that hold a certain position and uses the whole list but does not pick the same person twice before the entire list is exhausted?

Categories:
I have the same question (0)
  • mmollet Profile Picture
    3,187 on at

    To use all once before reusing simply add a column to that list called 'inUse'. If this is true or yes or 1 for example then we can tell the code to skip it. You can then update that when you use a name.

    Set(NewName, First(Shuffle(Filter(YourList, inUse = 1))));

    This should give you a random unused name stored in the variable NewName.

  • 3cdoug Profile Picture
    153 on at

    Do I add this to my already existing code in the on select property? 

     

    3cdoug_0-1683212668623.png

     

  • mmollet Profile Picture
    3,187 on at

    What I did was filter the list to remove all used names then take what was left and randomize it then grab the first name off the top of the list. This essentially gives you one of the random unused names from your list. This would be the only thing on the button's on select and would give you a variable that holds a single name. Also you will obviously have to make sure you adde the inUse col to your data source or that will throw an error. 

     

    Your error is partially coming from the word yes because it needs to be in quotes as it is a string -> "yes"

     

    EDIT: if you are using a yes/no column type then you will have to check for true/false instead of "yes"/"no". Yes/No columns in SP are simply bool column types. Yes = true and No = false. This would make your code to check look like this -> Set(NewName, First(Shuffle(Filter(YourList, inUse = true))));

     

    Again this will require you to make that column 'inUser' in your list and I would set default value to false/no if you are using Yes/No column type. This will also simply give you a variable that holds a name so that you can use it/assign it/ save it wherever you need to.

  • 3cdoug Profile Picture
    153 on at

    Okay, so it is still randomizing but it isn't removing the name or maybe I'm not understanding/properly explaining my goal. I have a gallery that displays the 8 names in my list, I hit my button and it does randomize the list but it doesn't remove them from the gallery nor does it change the sharepoint list column to true. I want to select the name, add it to a calendar, and not have that same name picked until everyname in the list has been selected

  • mmollet Profile Picture
    3,187 on at

    Yeah so what I gave you does most of that all you have to do is take that and add it to your calendar now. That code will grab you a random name from the list and will also keep track of what names have already been used. Now what you need to do is just add it to your calendar however you are wanting to do that. When you do add it, you will need to make sure to also update the column in 'inUse' to true so that it knows not to use that name again. Once all the names are used you can reset the values in that column and start over again etc. 

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard