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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter based on multip...
Power Apps
Unanswered

Filter based on multiple sources

(0) ShareShare
ReportReport
Posted on by 32

Hi

I've populated a UserList collection with basic info in

I want to search user and apply filters before a gallery lists the results.

Now the additional filters are going to be from different sources

 

so far I have under gallery> items:- (it complains about highlighted red)

Search(If(
CountRows(selectedEstab)>0,Filter(UsersList,Establishment in selectedEstab.Value),
CountRows(selectedStaffType)>0,Filter(UsersList,GroupType in selectedStaffType.Value),
CountRows(selectedTrain)>0,Filter(StaffTrainingRegister,course_completed in selectedTrain.Value, attendee_email in UsersList.mail)
),First(SearchUser).Value, "displayName")

 

the selected...... are collections populated by checked checkboxes 

StaffTrainingRegister is a excel table,

 

So I want to check if the searched staff have completed the selected training

 

Any ideas?

 

 

 

 

Categories:
  • WarrenBelz Profile Picture
    156,586 Most Valuable Professional on at

    Hi @ajl80 ,

    That is because you cannot have two different data sources conditionally in the Items of a gallery. The issue is that when referring to the gallery, the line items will have different references depending on what it is populated with.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • ajl80 Profile Picture
    32 on at

    OK thanks, I'm new to PowerApps! slowly picking it up!

    Another option I'll try is apply to a flexible height gallery and add the other sources filter/lookup to the visibility of the item or add columns to UserList from all the sources.   

  • WarrenBelz Profile Picture
    156,586 Most Valuable Professional on at

    Hi @ajl80 ,

    I use a far less elegant solution regularly - I have either multiple galleries with the Visibility set to the one I want to see, or do a Collection for the gallery Items and use RenameColumns/DropColumns on one of the lists if necessary to line up the field names in the collection.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • ajl80 Profile Picture
    32 on at

    OK, I have updated UsersList to include the training using:-

    AddColumns("Courses",Filter(StaffTrainingRegister,attendee_email=mail).course_completed)

    which now lists the courses for each user. (I've added a list in the gallery and set the items to ThisItem.Courses).

    Next I need to compare the selected courses with the courses each staff have listed.

     

    As before I am back to sorting the filters, I've tried

    CountRows(selectedTrain)>0, Filter(UsersList, Courses in selectedTrain.Value)

    now this worked with previous column values because there's only one value, where as Courses contains a list.

    Filter within a Filter or Concat? 

  • WarrenBelz Profile Picture
    156,586 Most Valuable Professional on at

    Hi @ajl80 ,

    Now it is getting complicated - when I mentioned AddColumns/DropColumns - I do this to ensure the lists are exactly the same in field name and field type and therefore any query will simply work. You also need to Filter GalleryName.AllItems (not the list name).

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • ajl80 Profile Picture
    32 on at

    Really sorry about this, its my first app with PowerApps, I'm not sure I follow

     

    GalleryName.AllItems didn't work in Items, So I've set Items as UserList and moved the following to the search button

    ForAll(Office365StaffGroups As groupRecord,
    Collect(UsersList, AddColumns(Office365Groups.ListGroupMembers(groupRecord.StaffGroupID).value,"GroupType",groupRecord.Title,"Establishment", groupRecord.StaffGroupEstab, "Courses",Filter(StaffTrainingRegister,attendee_email=mail).course_completed))
    );
    
    Search(If(
    CountRows(selectedEstab)>0,Filter(GallerySearchUser_1.AllItems,Establishment in selectedEstab.Value),
    CountRows(selectedStaffType)>0,Filter(GallerySearchUser_1.AllItems,GroupType in selectedStaffType.Value)
    //CountRows(selectedTrain)>0,Filter(UsersList, Courses in selectedTrain.Value)
    ),First(SearchUser).Value, "displayName");

    as you can see I'm getting all members of staff in different o365 groups then adding columns from different sources

  • WarrenBelz Profile Picture
    156,586 Most Valuable Professional on at

    @ajl80 ,

    It would have been good to put what you were actually doing in your first post - also can you please use Format Text and post in a Text box (the </> icon above) as below.

    ForAll(
     Office365StaffGroups As groupRecord,
     Collect(
     UsersList, 
     AddColumns(
     Office365Groups.ListGroupMembers(groupRecord.StaffGroupID).value,
     "GroupType",
     groupRecord.Title,
     "Establishment", 
     groupRecord.StaffGroupEstab, 
     "Courses",
     Filter(
     StaffTrainingRegister,
     attendee_email=mail
     ).course_completed
     )
     )
    );
    Search(
     If(
     CountRows(selectedEstab)>0,
     Filter(
     GallerySearchUser_1.AllItems,
     Establishment in selectedEstab.Value
     ),
     CountRows(selectedStaffType)>0,
     Filter(
     GallerySearchUser_1.AllItems,
     GroupType in selectedStaffType.Value
     ),
     CountRows(selectedTrain)>0,
     Filter(
     UsersList, 
     Courses in selectedTrain.Value
     )
     ),
     First(SearchUser).Value, 
     "displayName"
    )

    You really need to get the Items of the gallery into a collection (as I mentioned) - you cannot search different data sources within a gallery. 

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • WarrenBelz Profile Picture
    156,586 Most Valuable Professional on at

    Hi @ajl80 ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • ajl80 Profile Picture
    32 on at

    Hi @WarrenBelz 

    I've reworked the UserList collection to populate based on selected, instead of listing all then filtering it. I've also split the courses into separate SharePoint lists, which I'm trying to add to UsersList by matching the emails, which I'm not having much luck, it adds the column but doesn't add the completion date

     

    ForAll(
     selectedGroup As groupRecord,
     Collect(
     UsersList,
     AddColumns(
     Office365Groups.ListGroupMembers(groupRecord.StaffGroupID).value,
     "GroupType",
     groupRecord.Title,
     "Establishment",
     groupRecord.StaffGroupEstab
     ),
     AddColumns(
     completedFireTraining,
     "FireTraining",
     LookUp(
     UsersList,
     mail = completedFireTraining[@staff_email],
     completed_date
     )
     )
     )
    );
    Search(
     If(
     CountRows(selectedFilter) > 0 And "Fire Training" in selectedFilter.Value,
     Filter(
     UsersList,
     Not IsBlank(FireTraining)
     )
     ),
     First(SearchUser).Value,
     "displayName"
    );

     

  • WarrenBelz Profile Picture
    156,586 Most Valuable Professional on at

    @ajl80 ,

    You only need AddColumns once - I assume you are adding the columns to completedFireTraining

    ForAll(
     selectedGroup As groupRecord,
     Collect(
     UsersList,
     AddColumns(
     completedFireTraining,
     Office365Groups.ListGroupMembers(groupRecord.StaffGroupID).value,
     "GroupType",
     groupRecord.Title,
     "Establishment",
     groupRecord.StaffGroupEstab,
     "FireTraining",
     LookUp(
     UsersList,
     mail = staff_email,
     completed_date
     )
     )
     )
    );
    Search(
     If(
     CountRows(selectedFilter) > 0 And "Fire Training" in selectedFilter.Value,
     Filter(
     UsersList,
     Not IsBlank(FireTraining)
     )
     ),
     First(SearchUser).Value,
     "displayName"
    );

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard