web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Gallery show or hide I...
Power Apps
Unanswered

Gallery show or hide Items

(0) ShareShare
ReportReport
Posted on by

I have a gallery with Items bound to Collection

{ QuestionId: 1 , NextQuestionYes:2, ParentQuestion: , Visible:1 , Answer: Yes/No} 

{ QuestionId: 2 , NextQuestionYes:3, ParentQuestion1: , Visible:0 ,Answer: Yes/No} 

{ QuestionId: 3 , NextQuestionYes:4, ParentQuestion: 2, Visible:0 ,Answer: Yes/No} 

{ QuestionId: 4 , NextQuestionYes:, ParentQuestion: 3, Visible:0 ,Answer: Yes/No} 

 

I would like to initially show Q1 and then when he answers Q1 with Yes, Question 2 will be shown along with Q1. When Q2 in answered with Yes , Q1,2,3 will be shown. If he answers No to Q1 then the brnaching stops there. 

I will have multiple top level questions with user going through branching based on his answer. 

How can we do this, I tried maintaining two collections and use the filtered collection with Visible = 1 as items to Gallery but it resets user answer after each refresh.  Looking to see if we can use the original collection and somehow show or hide gallery item based on Visible property instead of filtering and creating a new collection. 

Categories:
I have the same question (0)
  • Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @Cnivas1 - one method based on what I think you're trying to do:

     

    1. Create the following Collection:

     

    ClearCollect(
     MyCollection,
     [
     {
     QuestionId: 1,
     Answer: [
     "Yes",
     "No"
     ],
     Display: true
     },
     {
     QuestionId: 2,
     Answer: [
     "Yes",
     "No"
     ],
     Display: false
     },
     {
     QuestionId: 3,
     Answer: [
     "Yes",
     "No"
     ],
     Display: false
     },
     {
     QuestionId: 4,
     Answer: [
     "Yes",
     "No"
     ],
     Display: false
     }
     ]
    )

     

    2. Set the Items property of the Gallery control to:

     

    Filter(
     MyCollection,
     Display
    )

     

    3. Embed a Dropdown control inside the Gallery (so the control is duplicated per the number of items in the Gallery).

     

    4. Set the Default property of the Dropdown to ""

     

    5. Set the AllowEmptySelection property of the Dropdown to true.

     

    6. Set the Items property of the Dropdown control to:

     

    ThisItem.Answer

     

    7. On the OnChange property of the Dropdown control, enter:

     

     

    UpdateIf(
     MyCollection,
     QuestionId = ThisItem.QuestionId + 1,
     {Display: Self.Selected.Value = "Yes"}
    )

     

  • RogierE Profile Picture
    875 Moderator on at

    So what I would advice you to do is to start with a collection to collect your Questions and answers with the clearcollect. I added some question descriptions and blank values were necessary:

     

    ClearCollect(colQuestions,[{ Question:"Question description",QuestionId: 1 , NextQuestionYes:2, ParentQuestion:Blank() , Visible:true , Answer: ""},
    { Question:"Question description",QuestionId: 2 , NextQuestionYes:3, ParentQuestion:1 , Visible:false ,Answer: ""},
    { Question:"Question description",QuestionId: 3 , NextQuestionYes:4, ParentQuestion: 2, Visible:false ,Answer: ""},
    { Question:"Question description",QuestionId: 4 , NextQuestionYes:Blank(), ParentQuestion: 3, Visible:false ,Answer: ""} ])
     
    Now once you do that you can create a Gallery with colQuestions as the Items source, and use the Question column for displaying your question and a dropdown for selecting the answer Yes or No
     
    The Dropdown would have 
    ["Yes","No"
    as Items and
    [ThisItem.Answer]
    as DefaultSelecteditems.  
     
    Now to save your answer, you would add this to the OnChange of the Dropdown:
    UpdateIf(colQuestions,QuestionId=ThisItem.QuestionId,{Answer:Self.Selected.Value})
     
    Then select all of the controls in your Gallery and add this to the Visible property:
    LookUp(colQuestions,QuestionId=ThisItem.ParentQuestion,Answer)="Yes" || ThisItem.QuestionId=1
     
    Note: the visible column in your collection is not necessary as a question will be shown if it is Question1 or if the parent Question has been answered positively.
     
    Please like the reply and accept it as the solution if the answer is what you were looking for.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard