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

Notifications

Announcements

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

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:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 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
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard