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 / Changing colour of a r...
Power Apps
Answered

Changing colour of a rectangle

(0) ShareShare
ReportReport
Posted on by 22

Please be gentle with me I am old and slow.

 

I have a number of rectangles overlaying an image of a body which are being used in indicate where an injury has taken place on the body.

 

I want the user to select the rectangle they want and for that rectangle to change colour and remained changed until the form has been submitted.

 

I have tried following on tutorial and even asked Bing AI but I keep getting an error, here is my workflow:

 

Circle1 selected

 

Onselect Set (Mycolor, True)

Fill If (Mycolor, Red,Blue)

 

as soon as I put the formula in FILL I get this error:

 

The function "If" has some invalid arguemnts

 

Location

Circle1

Fill

 

Can some kind soul show me where I am going wrong, because at this rate I might give up and spend an evening with my wife (so pleeeeese help)

 

 

Categories:
  • TheRobRush Profile Picture
    11,128 Moderator on at

    To demonstrate how this works, plac ea single rectangle on your screen. Set it's onselect to

    UpdateContext({amISelected:Self})

    and its fill to

    If(amISelected=Self,Color.DarkRed, Color.Blue)

    now copy and paste it ad nauseum and click around

  • Ticmic Profile Picture
    22 on at

    Thank you but how can I revert it back to the original colour if I have made a mistake

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Change OnSelect to

    Switch(
     amISelected, Self, UpdateContext({amISelected:Blank()}),
     UpdateContext({amISelected:Self}))
  • Verified answer
    TheRobRush Profile Picture
    11,128 Moderator on at

    and HERE is if you want to be able to select more than one at a time.


    OnSelect

    Switch(
     Self in selectionArray, true, RemoveIf(selectionArray, button=Self),
     Collect(selectionArray, {button:Self}))

     

    If(Self in selectionArray,Color.DarkRed, Color.Blue)
  • Ticmic Profile Picture
    22 on at

    Thank you so much for your assistance

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Anytime, don't forget to mark the post/posts that resolved your issue as Solutions so that people searching for your same issue in future will more easily find their answers

  • Ticmic Profile Picture
    22 on at

    Ok, one issue I now have is if I have multiple rectangles when I select one it turns the others off, how can I make it so I can choose multiple rectangles

  • Verified answer
    TheRobRush Profile Picture
    11,128 Moderator on at

    Look through my post above, I already provided a second method for selecting multiple rectangles

  • Verified answer
    Ticmic Profile Picture
    22 on at

    Sorry, I got so Giddy with the solution I missed it thanks again

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard