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 / Filtering gallery base...
Power Apps
Unanswered

Filtering gallery based on user role

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello there, I'm trying to figure out the best way to filter a gallery of records (using SharePoint) based one three different user roles. The roles are as follows:

 

1. User - Can only view records that THEY have created

2. Approver - Can view records that they have created AND records to to which THEY are the approver of (each record has an approver field of type person)

3. Admin - Can view ALL records (I'm assuming I would just simply not add a filter here)

 

I have boolean variables (isApprover and isAdmin) declared upon running the app that determine if the current user is of either the two roles. This is done with a lookup as a have two SharePoint lists containing all users for each role. I would like to avoid having 3 separate screens if possible. I feel like adding some sort of conditional filter would make sense. Something like "If(isApprover, Approver.Email = User().Email) or something of the sort. PowerApps gets a bit angry when I try putting conditional statements in a filter though. I'm a bit new to PowerApps so I'm sure there's something I'm not doing quite right. If anyone could help me out or tell me a better way of doing this, I would really appreciate it! Thanks!

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @Anonymous 

    I've written a full tutorial on how to do this.  Here's a link in case you'd like to check it out.  If you use my methods will can simply copy + paste the code from my app into yours and make the necessary changes.


    Tutorial: Designing A Role Based User Interface:
    https://matthewdevaney.com/designing-a-role-based-user-interface-in-power-apps/


    PowerApps-User-Roles-Demo.gif

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I can see that you want to create 3 different roles for your users and you want to filter your data according to their role.

    In this case first you have to create a new list of new column where you assign them their roles, after that you have to Use this code on items property of gallery - 

    If(
    LookUp(
    YourDataBaseName,
    EmailAddressColumn = User().Email
    ).DesignationColumn= "Role1",
    Filter(
    DataBaseMainName,
    StatusColumn= StatusyouwantforRole
    ),
    If(
    LookUp(
    YourDataBaseName,

    EmailAddressColumn = User().Email
    ).Designation.Value = "Role2",
    Filter(
    DataBaseMainName,
    StatusColumn = StatusyouwantforRole
    )
    )

     

     

    in this DataBases ,columns and required values you have to replace according to your data 

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 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard