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 gallery based o...
Power Apps
Suggested Answer

Filter gallery based on dropdown selection in Powerapps

(1) ShareShare
ReportReport
Posted on by 222
Hi,
 
I have a gallery that displays user data.
 
I would like to filter the gallery based on the logged in user as follows:
When a new application is created, the logged in user will need to complete a form and select the supervisor name and/or the department manager name from the drop down lists.
The request is saved to a sharepoint list.
 
We need to be able to filter the gallery as follows:
If the user is a manager, then filter all requests where the manager name field = drpmanager.selected.value.
If the user is a supervisor, then filter all requests where the supervisor name field = drpsupervisor.selected.value.
If the user is a HR manager, then display all requests.
If the user is the logged in user, then only show the user's request.
 
Kind regards
 
Rene Voller
Categories:
I have the same question (0)
  • Suggested answer
    Vish WR Profile Picture
    2,825 on at
     
    You could try like this 
    If(
        // HR Manager — see everything
        User().Email in HRManagersTable.Email,
        SharePointList,
        // Manager — see requests where they're the assigned manager
        User().Email in ManagersTable.Email,
        Filter(SharePointList, ManagerName = drpManager.Selected.Value),
        // Supervisor — see requests where they're the assigned supervisor
        User().Email in SupervisorsTable.Email,
        Filter(SharePointList, SupervisorName = drpSupervisor.Selected.Value),
        // Default — logged-in user sees only their own request
        Filter(SharePointList, StaffMemberEmail = User().Email)
    )
     
    Vishnu WR
     
    Please âœ… Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like â™¥
  • Suggested answer
    WarrenBelz Profile Picture
    155,288 Most Valuable Professional on at
    One item missing here is how you are querying for the user's role. I will give you a couple of exmples - firstly if you are using the JobTitle from Entra
    Switch(
       Office365Users.UserProfileV2(User().EntraObjectId).jobTitle,
       "HR Manager",
       YourSPList,
       "Supervisor",
       Filter(
          YourSPList,
          SuperFieldName = drpSupervisor.Selected.Value
       ),
       "Manager",
       Filter(
          YourSPList,
          ManagerFieldName = drpManager.Selected.Value
       ),
       Filter(
          YourSPList,
          'Created By'.Email = User().Email
       )
    )
    and if you are looking up another reference list (note I have assumed that the Manager and Supervisor fields are Single Line of Text - you would need after the field name .Value if a Choice/Lookup and .DisplayName if a Person field,
    Switch(
       LookUp(
          YourRefList,
          EmailField = User().Email
       ).Role,
       "HR Manager",
       YourSPList,
       "Supervisor",
       Filter(
          YourSPList,
          SuperFieldName = drpSupervisor.Selected.Value
       ),
       "Manager",
       Filter(
          YourSPList,
          ManagerFieldName = drpManager.Selected.Value
       ),
       Filter(
          YourSPList,
          'Created By'.Email = User().Email
       )
    )
     
    Please ✅ Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  
  • RVoller Profile Picture
    222 on at
     
    The Switch did not work.  The error I got was 'expecting a record when there is a text value'.  So I tried to add {} and {Value: }, but this did not work.
     
    So I tried the IF statement as suggested and this did not work either.
    If(varEditTask.'Approval Manager'.Email  = User().Email || varEditTask.'Created By'.Email = User().Email , Filter('Flex Working', 'Approval Manager'.Email = varEditTask.'Approval Manager'.Email),  
    If(varEditTask.'Approval Supervisor'.Email = User().Email || varEditTask.'Created By'.Email = User().Email, Filter('Flex Working', 'Approval Supervisor'.Email = varEditTask.'Approval Supervisor'.Email),  
    Filter('Flex Working', 'Staff Member'.Email= User().Email)))
     
    Essentially, if the logged in user = Approval manager column in the sharepoint list, then list all the records.  This should include all child records. Any record where the approval manager = logged in user.
    If the approval manager is also the approval supervisor, then these child records should show.
     
    If the logged in user = approval supervisor column in the sharepoint list, then list all the records.  This should include all requests that have to be approved by the supervisor.  
    The supervisor should not see the manager's requests, but the manager must see all requests.
     
    Any other suggestions?
     
    Kind regards
     
    Rene Voller
     
     
     
  • WarrenBelz Profile Picture
    155,288 Most Valuable Professional on at
    This is really a matter of me getting my mind around the logic you require - based on what you have posted, I am assuming the following: -
    • varEditTask contains three Person fields (can you please post how you set this) 'Created by' (standard SP field) ,'Approval Manager' and 'Approval Supervisor'
    • Your SharePoint List 'Flex Working' also contains Person fields 'Approval Manager' and 'Approval Supervisor'
    Based on the code you posted
    If(
       varEditTask.'Approval Manager'.Email = User().Email || varEditTask.'Created By'.Email = User().Email , 
       Filter(
          'Flex Working', 
          'Approval Manager'.Email = varEditTask.'Approval Manager'.Email
       ),  
       varEditTask.'Approval Supervisor'.Email = User().Email || varEditTask.'Created By'.Email = User().Email, 
       Filter(
          'Flex Working', 
          'Approval Supervisor'.Email = varEditTask.'Approval Supervisor'.Email
       ),  
       Filter(
          'Flex Working', 
          'Staff Member'.Email= User().Email
       )
    )
    • When the Approval Manager is in varEditTask, they see all records in 'Flex Working' where either they are listed in the 'Approval Manager' field OR the record was created by them.
    • When the Approval Supervisor is in varEditTask, they see all records in 'Flex Working' where either they are listed in 'Approval Supervisor' field OR the record was created by them.
    • Everyone else sees only records where they are in 'Staff Member' in 'Flex Working'
    What I am trying to understand is what are the "child records" you are referring to ? Bear in mind I cannot see your data structure.
     
    Please ✅ Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,074

#2
Valantis Profile Picture

Valantis 639

#3
11manish Profile Picture

11manish 606

Last 30 days Overall leaderboard