cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
iwonder
Impactful Individual
Impactful Individual

Conditionally Show fields in Gallery

Thank you for taking the time to read my question.

 

I have a table with many columns. I want to show the results in a Gallery, however at any given time, some columns are useful and others are not.

 

Is there a way to allow the user to select what columns they want to see and hide the rest?

 

I tried the following but PowerApps doesn't like it... I did 🙂

 

ForAll(colFields As tVal,If(!IsBlank(LookUp(colFields,tVal.tFields = tFields)),UpdateContext({"varVis" & tVal.tFields:true}) ,UpdateContext({"varVis" & tVal.tFields:false})))

 

I was thinking I could make up the Context variable name on the fly based on a string and the current value in the ForAll, but that's failing. Of course I can't use Set() either.

 

Is this possible?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@iwonder 

You cannot reference column names like that.  They must be hand-written in the formula as they are.

I'm not sure what your collection is, but you can also do all of this from a combobox of column names.

 

Example, A combobox with all the column names listed in it and the user could select from them to turn them on and off.

Combobox Items property:  ["Column1", "Column2", "Column3"]

If you want them all to be visible when you first access the screen, then set the DefaultSelectedItems property to: ["Column1", "Column2", "Column3"]

 

Then in your gallery, for the columns you want to control, set the visible property to (example Column1): "Column1" in comboboxName.SelectedItems

Repeat for the other columns with their names.

 

That should give you what you want.

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@iwonder 

You cannot reference column names like that.  They must be hand-written in the formula as they are.

I'm not sure what your collection is, but you can also do all of this from a combobox of column names.

 

Example, A combobox with all the column names listed in it and the user could select from them to turn them on and off.

Combobox Items property:  ["Column1", "Column2", "Column3"]

If you want them all to be visible when you first access the screen, then set the DefaultSelectedItems property to: ["Column1", "Column2", "Column3"]

 

Then in your gallery, for the columns you want to control, set the visible property to (example Column1): "Column1" in comboboxName.SelectedItems

Repeat for the other columns with their names.

 

That should give you what you want.

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

CNT
Super User
Super User

@iwonder If it is just to display data, you can use a DataTable and set the Visible property of the Data Table Column to true/false depending on the user selection.

CNT_0-1639001076476.png

 

iwonder
Impactful Individual
Impactful Individual

I was WAY over thinking it.... Thanks Randy.

 

I guess the next issue would be to try and get the fields to float to the left...

RandyHayes
Super User
Super User

@iwonder 

Keep it super simple!! Always a rule in PowerApps!

 

You can alter the X properties for the controls you want to move around based on conditions.

I am not sure of your floating needs, but I am guessing that you want to have all the controls line up horizontally with no spacing between them if the field between them is not visible?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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