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 / PowerApps Gallery Filt...
Power Apps
Answered

PowerApps Gallery Filtering SharePoint Library Based on User Group Memberships

(0) ShareShare
ReportReport
Posted on by 18

Hi Everyone,

 

I have a SharePoint Document library in which i have a people picker field (AccessGroups) to allow multiple selection (Only Groups are added in it). Now i want to filter the library in PowerApps in such a way that if the current user is member of any one group (basically Departments) from the groups mentioned in the people picker field, those documents only should be visible to user.

 

For example in the below image, if the current logged user is a member of Account Group and All Company Members, then the user should only see Policy 2, Policy 3 and Policy 4. User should not be able to see Policy 1. 

Hari_Ree27_0-1709171321233.png

 

Can anyone please help on this?

 

I tried filtering like below but it is showing blank Gallery.

Filter('Test Library', User().Email in AccessGroup.Email

 

Filter Gallery.png
Categories:
  • EddieE Profile Picture
    4,650 Moderator on at

    @Hari_Ree27 

    You could try using the Office365Groups connector and get a List of Groups the logged in User is a member of. Eg

     

    Add this code to a button and review the created collection. This will show Groups you are a member of:

     

    ClearCollect(
     colMyGroups_test,
     ForAll(Office365Groups.ListOwnedGroupsV3().value As groups,
     {
     groupName: groups.displayName
     }
     )
    )

     

     

    From there, you should be able to filter based on Group displayName in your gallery. I realise this is only part of the answer but if you need further help, let me know.

     

    Connector details

    https://learn.microsoft.com/en-us/connectors/office365groups/

     

  • Hari_Ree27 Profile Picture
    18 on at

    @EddieE  Thanks for the reply. I created a collection as suggested by you but the collection is showing only groups that i owned (i.e., I am the owner of those groups). It is not showing groups that I am a member of. I used V3 only.

     

    ClearCollect(
        colUserGroups,
        ForAll(
            Office365Groups.ListOwnedGroupsV3().value As groups,
            {
                MyGroups: groups.displayName
            }
        )
    );
     

    And also can  you please let me know how to compare the group names with the groups from the AccessGroup field.. 

  • EddieE Profile Picture
    4,650 Moderator on at

    @Hari_Ree27 

    Try doing a CountRows on that collection, I think it has a Max return value count, ie

    // put this on a label
    CountRows(colMyGroups_test)

     

    The documentation for V3 says it returns ' ... own and belong to.' so should return both, ie

    EddieE_0-1709192348804.png

    My collection shows both for me.

     

    The 2nd part is trickier. You'd need to get the Display Names of each group and check against that collection.

     

    In an app I've built I do something similar in reverse. My process is

    - Use Power Automate to get the Group IDs of 18 Groups I'm interested in

    - I then hard code these Group IDs / GUIDs into a collection in my App OnStart

    - Users use a People Picker ComboBox to select a person from our AD

    - I then run a check to see which of the 18 Groups the selected person is a member of -  this users the selected person UPN and Email to check.

     

    The process I've built is reasonably complex but I'm happy to share it if you think it'll help but like I said above, I'm kind of doing the reverse to what you are try to achieve.

  • Hari_Ree27 Profile Picture
    18 on at

    @EddieE I tried the CountRows and it is showing value as 3 which i Owned. V3 isn't working for me to fetch the group names which I am a member of. Is there any settings that need to be done or level of permissions that i need to get those details please guide me through.

  • EddieE Profile Picture
    4,650 Moderator on at

    @Hari_Ree27 

    I'm unsure why this isn't working for you, it just works for me without issue. Maybe there's something setup in your Tenant that needs adjusting but I wouldn't know what/where this is.

     

    @v-jefferni would you have an idea of why the above connector is only returning 3 Owned Groups and not Member Groups for @Hari_Ree27 ?

  • Verified answer
    Hari_Ree27 Profile Picture
    18 on at

    @EddieE  Just wanted to drop a quick note to express my gratitude for your support. I managed to achieve the desired outcome through a slightly different approach. Instead of fetching all the groups the user is a member of and searching for them in the Access Group field, I decided to take a different route. I utilized 

    Office365Users.MyProfile().Department

    to retrieve the user's department and then cross-checked if that department is listed among the display names of the Access groups. If it's found, the document shows up; otherwise, it stays hidden. While I still encounter some delegation issues, the solution is up and running for now. Thanks again for your help!

  • EddieE Profile Picture
    4,650 Moderator on at

    @Hari_Ree27 

    Nice work mate, and happy I could be of some assistance / inspiration 🙂 

     

    It's nice also that you have .Department data available to use - the AD in our Org changes quickly and a lot so the AD is typically out-of-date and not something I can leverage in my work.

     

    Happy PowerApping 🙂

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard