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

@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
Memorable Member
Memorable Member

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

 

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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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