Use Objects with a Condition in Gallery
We can design lists with a condition in the gallery by writing the If formula. With these conditions, it is possible to control a lot of features of objects like color, view, size, position. You can authorize based on person/department, hide/show buttons on the screen and highlight status in case of tracking.
Use Objects with a Condition in the Gallery
We will be going over how to show different objects for different question types in the gallery. This way, one question in the same group will be replied with the radio button and the other will be replied with rating.
Create a Collection
We will create a sample collection for an example with the data above. You need to create the collection by writing the code below into the OnSelect property of a button we will add to the screen.
Question_type: “Radio” }
Question_type: “Rating” }
Question_type: “Slider” }
Show Objects in the Gallery
You need to add the Gallery object to the screen in order to do the action in the example. Questions collection should be connected to this gallery object’s Items.
The responding way of each question in the collection is indicated in the Question_type column. Depending on the responding way of questions, Radio Button, Rating and Slider has been added to the gallery. IF formulas will be written into the Visible property of each object and thus, the related item will be shown depending on the question type and the other ones will be hidden.
Radio Button Visible Code: If(ThisItem.Question_type=”Radio”;true;false)
Rating Visible Code: If(ThisItem.Question_type=”Rating”;true;false)
Slider Visible Code: If(ThisItem.Question_type=”Slider”;true;false)
You can click here to take a look at other Power Apps articles.
You can click here to take a look at the use of IF function.