cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
russrimm1
Helper II
Helper II

Gallery filtering

Hi all,

I'm working on a survey PowerApp that's sourced from a Sharepoint list of questions.  There will be multiple respondents during the survey, and depending on their role, they will or will not get asked each question.   

 

The problem I'm struggling with is, I have a "filter answered questions" checkbox that I'm struggling to filter out ONLY after two or more people answer a question targeted to two or more people.  I'm creating a collection of answeredquestions, and if I use the following filter, it will filter the question as soon as one of the two respondents answers the question (because of the Not(ID in answeredquestions.QuestionID).  I want it to filter the question out only if there's a question from ALL respondents.

 

Filter(colSurveyQuestions, Not(ID in answeredquestions.QuestionID) &&
!IsEmpty(
Filter(
interviewees,
Role in PersonaTargets.Value && ID in interviewees.ID
)
)

 

answered.JPG

questions.JPG

interviewees.JPG

3 REPLIES 3
BCLS776
Super User
Super User

Without knowing a lot about your data structure, I'll suggest this: Can you add a column in one of your SP lists that tracks the number of times a question has been answered? Then, you could filter out questions using that column as one of your criteria. It would save building extra internal collections.

 

Would that fit with your app? 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

@BCLS776 Unfortunately not because these questions are going to be asked over and over to many different people, but only 1-5 people will be in the room at a time, so I have a listbox that shows the names of the people who have a persona that applies to each question and then each question is saved to a single datasource.  I basically want a way to check to see if 100% of the 1-5 people in the room have completed each question or not.  I'm doing a countrows comparison to make the Fill color of each gallery item change which is working, but I'm struggling with how to filter the completed ones out of the gallery completely.  If I could somehow use the same CountRows check to cause them to filter, that would probalby be easiest, but not sure if that's possible.

OK, I understand better the need for working with internal collections in your case.

 

So, let's work on the logic of your filters. Here's your code again:

Filter(colSurveyQuestions, 
    Not(ID in answeredquestions.QuestionID) &&
    !IsEmpty(
        Filter(interviewees,
            Role in PersonaTargets.Value && ID in interviewees.ID
        )
    )
)

In words, I'll describe how I read this:

  1. Filter colSurveyQuestions to exclude questions in answeredquestions, AND do this only when...
  2. A filter of interviewees by Role shows up in the column PersonaTargets (but, this in colSurveyQuestions) AND a further filter of interviewees ID = interviewees ID (always true)

The stuff in the Lookup() described in 2 above has some issues. I believe you are trying to check if colSurveyQuestions has records applicable to the Role from interviewees, but that isn't what is happening.

 

Assuming PersonaTargets originates from a choice column with multiple selections, this code should work better:

Filter(colSurveyQuestions, 
    Not(ID in answeredquestions.QuestionID) &&
    !IsEmpty(
        Filter(interviewees,
            Role in Concat(colSurveyQuestions.PersonaTargets,Value,", ")
        )
    )
)

I removed the part about checking interviewees.ID - I didn't understand the purpose of that. You may have a good reason to filter based on ID, but it should not be circular as before.

Try it out and let us know how it goes,

Bryan

  

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (4,031)