Showing results for 
Search instead for 
Did you mean: 
Level 8

Conditional Gallery Visibility

I have an app with two galleries. The first has a list of operating systems and the second a list of devices with the selected operating system. 


I would like to hide the devices gallery until the user makes a selection in the OS gallery. I first tried with a context variable (ctx_ShowModels). In the screen's OnVisible property, I had: UpdateContext({ctx_ShowModels:false}). Then, the OnSelect of the image in the OS gallery had UpdateContext({ctx_ShowModels:true}). Finally, in the Visible property for the devices gallery, I put ctx_ShowModels. However, this results in the following error message:


I tried the same using a global variable, and got the same result. I know there has to be a way to do this, but for the life of me, cannot figure it out. 


PS: this is an app that's in use right now by faculty at our University to select new computers. I was curious as to why so many folks - even people who I know are not Mac users - were selecting the Macbook Pro. One of those non-Mac people called me to complain that they were "forced" to select a Mac; believing that because the Macs were visible before they chose their desired platform, those were the suggested or recommended choice.



Level 10

Re: Conditional Gallery Visibility

Hi @ChadVKealey,


By default, the first item of the gallery is selected. Sometimes I agree this is an undesired behavior. 

What if you set your context variable accordingly to the selected items ?

Let's say, Mac ID = 1 / Windows ID = 2, and your machines have ID_OS = 1 or 2. (I'm just making assumptions to explain my thoughts, just keep using your current data structure with the logic I'll explain)


You can try :

Screen.OnVisible : UpdateContext({selectedOS=0})

GalleryOS.OnSelect : UpdateContext({selectedOS=ThisItem.ID})

GalleryMachines.Items : Filter(Machines,ID_OS=selectedOS)

GalleryMachines.Visible : selectedOS <> 0


I'm not sure it will work I'm just trying to workaround your error and avoid using a boolean context value. 

I haven't seen this error before. 



Level 10

Re: Conditional Gallery Visibility



@tchin-nin has a point on using in number variable instead off a boolean. This is simple because a number value can have a lot off states, where a boolean can just have two. There is a lot off power in using number variables and I post some video to show how you can use this to your benefit. See: Learn PowerApps Blog and start at video 13 if you like to see those tricks.


In this case I would advise to make a text variable and use the UpdateContext() formula to set it like



Put this on the datacard.OnSelect and on the picture.OnSelect you then do this


Then on the Gallery2.Visible you use this formula


So when it is not set the variable is blank and the gallary is not visible.


Btw, when you use the variable as a condition in your filter then make the gallary not visible is not even needed. This because the gallery is empty as long as you did not select an OS. Use the formula:

Filter(Datasource, OS = YourOS)


Then on leaving the screen you reset the variable like:


Don't use Blank() here, be specific so PowerApps understands what you want ;-)


Hope this helps.



Community Support Team
Community Support Team

Re: Conditional Gallery Visibility

Hi @ChadVKealey,

Based on the error message that you provided, I think you have faced a Select Cycle error within your app. Usually the error occurs when control-A trying to invoke control-B and control-B has been calling Control-A already.

The user @PowerAppJammer has faced same issue with you, please check the response within the following thread:

Please take a try to remove the UpdateContext formula from the OnVisible property of the first screen of your app, then check if the issue is solved.

I have made a test on my side, and don't have the issue that you mentioned. Please also take a try with the following workaround:

Set the OnVisible proeprty of the OS Gallery to following:


Set the OnSelect property of the OS Gallery or the Image within the OS Gallery to following:


Set the Visible property of the Devices Gallery to following:



If the issue still exists, please take a try to re-create your app, then check if the issue is solved.


Best regards,


Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Level: Powered On

Re: Conditional Gallery Visibility


  1. Screen: On Visible: Set(ShowVar, false)
  2. Platform_Gallery: On Select= Set(ShowVar,true)
  3. Model_Gallery: Visible=ShowVar