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.
Solved! Go to Solution.
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"]
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)
)
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 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)
)
It says there is an unexpected operated is something wrong with the syntax? @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.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
User | Count |
---|---|
193 | |
95 | |
62 | |
59 | |
58 |
User | Count |
---|---|
252 | |
164 | |
93 | |
79 | |
70 |