cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
powerapps890
Post Prodigy
Post Prodigy

Change color of shape based on radio button

I have a radio button with three choices and this is the code for the fill on a shape If(Radio1.Selected.Value = "Works", RGBA(0,255,0,.5), Radio1.Selected.Value = "Has issues", RGBA(255,255,0,.5), Radio1.Selected.Value = "Does not work", RGBA(255,0,0,.6)). The shape defaults to black how can I make it default to white? Also for some reason the first time I click the radio button it will default the rest of the shapes to that color. But the other shapes should stay blank until the radio button is selected. 

1 ACCEPTED SOLUTION

Accepted Solutions
ganeshsanap
Super User
Super User

@powerapps890 Follow below steps:

  1. Create a collection for Radio button choices as:

 

ClearCollect(RadioItems, "Works","Has issues","Does not work")

 

  • Add radio button and set it's Items property to RadioItems.Value.
  • Add a shape (Ex. circle) and select set its Fill property to:

 

If(IsBlankOrError(Radio1.Selected.Value), Color.White, Radio1.Selected.Value = "Works", RGBA(0,255,0,.5), Radio1.Selected.Value = "Has issues", RGBA(255,255,0,.5), Radio1.Selected.Value = "Does not work", RGBA(255,0,0,.6))

 


Please click Accept as solution if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it 👍

 

View solution in original post

7 REPLIES 7
eka24
Super User
Super User

Try

If(Radio1.Selected.Value = "",White,

Radio1.Selected.Value = "Works", RGBA(0,255,0,.5), Radio1.Selected.Value = "Has issues", RGBA(255,255,0,.5), Radio1.Selected.Value = "Does not work", RGBA(255,0,0,.6))

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

The shape is still black, it didn't work. @eka24 

ganeshsanap
Super User
Super User

@powerapps890 Follow below steps:

  1. Create a collection for Radio button choices as:

 

ClearCollect(RadioItems, "Works","Has issues","Does not work")

 

  • Add radio button and set it's Items property to RadioItems.Value.
  • Add a shape (Ex. circle) and select set its Fill property to:

 

If(IsBlankOrError(Radio1.Selected.Value), Color.White, Radio1.Selected.Value = "Works", RGBA(0,255,0,.5), Radio1.Selected.Value = "Has issues", RGBA(255,255,0,.5), Radio1.Selected.Value = "Does not work", RGBA(255,0,0,.6))

 


Please click Accept as solution if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it 👍

 

View solution in original post

This works, but there is an issue. If I choose works it will make the first one green and then the next few are still white, but the remaining are green. Why are the rest turning green when they haven't even been selected? @ganeshsanap 

What if you try this:
If(IsBlankOrError(Radio1.Selected.Value), Color.White, Radio1.Selected.Value = "Works", RGBA(0,255,0,.5), Radio1.Selected.Value = "Has issues", RGBA(255,255,0,.5), Radio1.Selected.Value = "Does not work", RGBA(255,0,0,.6), Color.White)

@powerapps890 Are you using the same formula and same Radio button for all the shapes? If the radio buttons are different for some shapes then make sure you are referencing to correct radio button in the formula.


Please click Accept as solution if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it 👍

 

Yes, it is all in the gallery so there is only one kind of shape and radio button repeated for each item. For some reason when filtering, it will automatically make the color of the first selected button the rest of unselected radio items. @ganeshsanap 

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,374)