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

Filtering causes color change of shapes

On my onvisible I create the radio collection. 

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))

This is the fill for my shape in the gallery. The problem is whenever I filter, it will change all the radio buttons that have not yet been selected to the color of the shape based on the radio button. Is there a way to get around this because I want the shape to remain white until the radio button is pressed.  

1 ACCEPTED SOLUTION

Accepted Solutions
Alex_10
Memorable Member
Memorable Member

it look like a radio button must be always selected to make the conditional code work properly.
What if you try:

 

If(
IsBlankOrError(Radio1.Selected.Value), Color.White,
Radio1.Selected.Value = "Not specified", 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)
)

 

Radio1.default = "Not specified"


Radio1.items = ["Not specified","Works", "Has issues", "Does not work"]

 

View solution in original post

14 REPLIES 14
justair007
Helper I
Helper I

@powerapps890 

The problem is that your collection needs to have a unique ID to reference each item in your gallery. So when you filter, the Radio button fill won't change since it refers to the unique ID.

 

Create a collection with two columns, 1 for the ID and 1 for the radio selection value.

Then on the OnChange event for the radio button, you need an If statement that first checks if there is an existing user selection for that radio button, if not, collect the ID and the radio button selection. If there is an existing selection for that radio button, patch the users new selection.

 

If(
    IsBlank(
        LookUp(
            colRadio,
            Id = ThisItem.Id
        )
    ),
    Collect(
        colRadio,
        {
            Id: ThisItem.Id
            RadioSelection: RadioButton.Selected.Value
        }
    ),
    Patch(
        colRadio,
        {Id: ThisItem.Id},
        {RadioSelection: RadioButton.Selected.Value}
    )
)

 

 Then use the collection in the fill for the radio button:

 

If(
    LookUp(
        colRadio,
        Id = ThisItem.Id,
        RadioSelection
    ) = "Works",
    RGBA(0,255,0,.5
    ),
    LookUp(
        colRadio,
        Id = ThisItem.Id,
        RadioSelection
    ) = "Has issues",
    RGBA(255,255,0,.5
    ),
       LookUp(
        colRadio,
        Id = ThisItem.Id,
        RadioSelection
    ) = "Does not work",
    RGBA(255,0,0,.6
    ),
    RGBA(0,0,0,0)
)

 

justair007
Helper I
Helper I

@powerapps890 

The problem is that your collection needs to have a unique ID to reference each item in your gallery. So when you filter, the Radio button fill won't change since it refers to the unique ID.

Create a collection with two columns, 1 for the ID and 1 for the radio selection value.

Then on the OnChange event for the radio button, you need an If statement that first checks if there is an existing user selection for that radio button, if not, collect the ID and the radio button selection. If there is an existing selection for that radio button, patch the users new selection.

 

If(
    IsBlank(
        LookUp(
            colRadio,
            Id = ThisItem.Id
        )
    ),
    Collect(
        colRadio,
        {
            Id: ThisItem.Id
            RadioSelection: RadioButton.Selected.Value
        }
    ),
    Patch(
        colRadio,
        {Id: ThisItem.Id},
        {RadioSelection: RadioButton.Selected.Value}
    )
)

 

 Then use the collection in the fill for the radio button:

 

If(
    LookUp(
        colRadio,
        Id = ThisItem.Id,
        RadioSelection
    ) = "Works",
    RGBA(0,255,0,.5
    ),
    LookUp(
        colRadio,
        Id = ThisItem.Id,
        RadioSelection
    ) = "Has issues",
    RGBA(255,255,0,.5
    ),
       LookUp(
        colRadio,
        Id = ThisItem.Id,
        RadioSelection
    ) = "Does not work",
    RGBA(255,0,0,.6
    ),
    RGBA(0,0,0,0)
)

 

 

powerapps890
Post Prodigy
Post Prodigy

@justair007 I am not sure where your response went, but I put those two in and it said there was a problem with the first if function. is there anything else I need to add besides those two statements.

@powerapps890 I'm not sure why the response is gone either. I re-posted it 3 times and it keeps disappearing 😞

 

Did you create the collection before trying to use it anywhere? I would add a button and them on the OnSelect event:

Collect(
        colRadio,
        {
            Id: "",
            RadioSelection:""
        }
)

@powerapps890 after you create the collection you need to use it in the OnChange event in conjunction with a patch inside an If statement to see if the user has already selected the radio button. If the user has selected the radio button, the new selection will patch to the collection:

 

 

If(
    IsBlank(
        LookUp(
            colRadio,
            Id = ThisItem.Id
        )
    ),
    Collect(
        colRadio,
        {
            Id = ThisItem.Id,
            RadioSelection: RadioButton.Selected.Value
        }
    ),
    Patch(
        colRadio,
        {Id = ThisItem.Id},
        {RadioSelection: RadioButton.Selected.Value}
    )
)

 

 

Then on the Fill property, use the collection to switch the color:

 

 

If(
    LookUp(
        colRadio,
        Id = ThisItem.Id,
        RadioSelection
    ) = "Pass",
    RGBA(0,230,64,.7)
,
    LookUp(
        colRadio,
        Id = ThisItem.Id,
        RadioSelection
    ) = "Fail",
    RGBA(207,0,15,.8)
,
    LookUp(
        colRadio,
        Id = ThisItem.Id,
        RadioSelection
    ) = "Something else",
    RGBA(207,0,15,.8),
    RGBA(0,0,0,0)
)

 

 

 

Capture.PNG

It says there is an unexpected operated is something wrong with the syntax? @justair007 

It also says that ID = ThisItem.ID is an incompatible type @justair007 

@powerapps890 hard to tell whats wrong exactly, the syntax looks fine. But it doesn't look like the code is on a control inside of a gallery.

@powerapps890 does your data have a column "ID" in it? It needs to have this. It also needs to be unique, like an index.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (1,652)