Hi @powerpepper
I had some errors in my previous answer, lets take a different approach
The current issue arises because the Lookup and Not functions are not supported in the way I was trying to use them, and there are issues with the data types. Instead, lets use a combination of ForAll, Filter, and CountIf to ensure that the gallery displays items that meet all criteria specified by the selections in the ComboBox.
First, ensure you have a variable to toggle between "View My Requests" and "View All Requests". Let's assume you have a variable called showMyRequests.
Here’s how to update your Gallery’s Items property:
If(
!showMyRequests,
Filter(
'SharePoint List Name',
CountIf('Submitted by', DisplayName = Office365Users.MyProfileV2().displayName) > 0 ||
CountIf('Assigned to', DisplayName = Office365Users.MyProfileV2().displayName) > 0
),
'SharePoint List Name'
)
- Filter: Filters the SharePoint list based on whether the current user is in the 'Submitted by' or 'Assigned to' fields.
- CountIf: Checks if the current user is included in the multi-select fields. CountIf returns the count of matches, and we check if this count is greater than 0.
- showMyRequests: A boolean variable used to toggle between showing requests by the current user or all requests.
If your dataset grows, you may encounter delegation warnings. Power Apps has limits on the amount of data that can be processed client-side, and not all functions are delegable. For now, as your dataset is within limits, this approach should work. In the future, consider loading your data into a collection first and then applying filters on the collection to avoid delegation issues.
If you want to prepare for larger datasets, you can load your data into a collection:
OnVisible Property of the Screen:
ClearCollect(allRequests, 'SharePoint List Name');
Gallery Items Property:
If(
!showMyRequests,
Filter(
allRequests,
CountIf('Submitted by', DisplayName = Office365Users.MyProfileV2().displayName) > 0 ||
CountIf('Assigned to', DisplayName = Office365Users.MyProfileV2().displayName) > 0
),
allRequests
)
This way, you can handle larger datasets more efficiently.