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 / Patch random item in c...
Power Apps
Answered

Patch random item in collection

(0) ShareShare
ReportReport
Posted on by 34

I want to set a user 1 of 6 colours when they first start the app. I have a User table with a Profile Colour column, I also have a collection with 6 different colours in it. Any idea how I can randomly patch one of the colours in the collection to the Profile Colour column?

Categories:
I have the same question (0)
  • Verified answer
    Adrian_Celis Profile Picture
    1,652 Moderator on at

    Hi @philkky12 

     

    First, your collection should be something like this:

     

    ClearCollect(ColorsCollection,
    Table(
     {Number:0,Color:"Green"},
     {Number:1,Color:"Yellow"},
     {Number:2,Color:"Red"},
     {Number:3,Color:"Blue"},
     {Number:4,Color:"Black"},
     {Number:5,Color:"White"}
    )
    )

    Then you can patch your table like this

    Patch(User,TheRecordThatYouWantToPatchHere,
    {'Profile Colour':LookUp(ColorsCollection,Number = Round(Rand()*5,0)).Color}
    )

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard