Showing results for 
Search instead for 
Did you mean: 
Helper III
Helper III

Only the Last Items in Gallery set variable right?

I have a Gallery like that:

Screen Shot 2019-11-30 at 12.50.56 PM.png


DataSource: colServices (a Collection, has Section Property: 1,2,3..., Request: true, false)


Default: ThisItem.Request

OnChange: Patch(colServices, ThisItem, Request = Toggle.Value)

OnCheck: UpdateContext({varEdit: ThisItem.Section})
OnUncheck: UpdateContext({varEdit: 0})

This variable will set the display mode of the component in the gallery.

Component.DisplayMode: If(varEdit = ThisItem.Section, Edit, View)


But Only the Last Item (Sectionm = 8 ) in Gallery has the right Effect (Please see the picture above)

The other items will set the varEdit=ThisItem.Section in a moment (0.1s), then change it to 0 after. (See the picture below)

Screen Shot 2019-11-30 at 12.51.58 PM.png



Please explain and help me!


Super User II
Super User II



You're only setting one variable to that value, so the last action to effect it will be the only one to show correctly 😺


So what's happening is that your gallery is going through and each time the toggle changes value its doing:

UpdateContext({varEdit: ThisItem.Section}) which is setting it to like 1,2,3,4,etc, and then 8, (the last one that is OnChecked)


and then its checking

If(varEdit = ThisItem.Section, Edit, View)

for each of your items, but varEdit is 8 now, so none of the others will be in edit mode as 8 = 8 is the only true value


So what I would do instead is set your component DisplayMode as:

If(Toggle1.Value=true, Edit, View)

- this will be evaluated individually in gallery rows so should Edit the ones that are checked only.



Could you give that a try and let me know whether it worked for you?





Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!

You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP

Helpful resources


Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users


We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Kudoed Authors
Users online (38,284)