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 by curr...
Power Apps
Answered

Filter gallery by current user, but allow a super user to view all gallery items

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am currently filtering my gallery with the following, where varUser = User() and supervisingHCP is a complex people column in sharepoint.

 

SortByColumns(Filter(BMPatientList, SupervisingHCP.DisplayName = varUser.FullName), "RoomNumber", Ascending)

 

I like how this works, but I would like to have a certain user, or group of users to have access to the entire gallery. Could I set up an IF statement to filter, where:

 

IF(varUser.Fullname = *name*, SortByColumns(BMPatientList, "RoomNumber", Ascending), SortByColumns(Filter(BMPatientList, SupervisingHCP.DisplayName = varUser.FullName), "RoomNumber", Ascending))

 

If that works, is there a way to use the IF argument to include multiple names, instead of just one?

Categories:
  • eka24 Profile Picture
    20,925 on at
    If(var.FullName="Abc",
    SortByColumns(BMPatientList), "RoomNumber", Ascending),
    SortByColumns(Filter(BMPatientList, SupervisingHCP.DisplayName = varUser.FullName), "RoomNumber", Ascending)
  • Verified answer
    WarrenBelz Profile Picture
    156,536 Most Valuable Professional on at

    Hi @Anonymous ,

    I assume you are hard-coding the names

    If(
     varUser.Fullname = *name* || varUser.Fullname = *name2* || varUser.Fullname = *name3*,
     SortByColumns(
     BMPatientList, 
     "RoomNumber", 
     Ascending
     ), 
     SortByColumns(
     Filter(
     BMPatientList, 
     SupervisingHCP.DisplayName = varUser.FullName
     ), 
     "RoomNumber", 
     Ascending
     )
    )

     

    Please click Accept as solution 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 giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz ,

    Thank you again for your help, you are fast!

     

    Hard coding was where my brain initially went. Perhaps there is more elegant solution that I will think of.

  • eka24 Profile Picture
    20,925 on at
    You can have a groupcolumn in your Usertable. Then set a Variable to pick the group name associated with the user anytime users login: Set(MyGroup,Lookup(UserTable,UserNameColumn=User().FullName,GroupName))

    Then apply this:
    If(MyGroup="Supervisor",
    SortByColumns(BMPatientList), "RoomNumber", Ascending),
    SortByColumns(Filter(BMPatientList, GroupColumn = MyGroup), "RoomNumber", Ascending)

    Note: You need to have a groupname column in BMPatientList to enable you filter.
  • Verified answer
    WarrenBelz Profile Picture
    156,536 Most Valuable Professional on at

    Hi @Anonymous ,

    Yes, possibly the easiest is a control list with the user's name and permissions. Once set up, it can be used for all sorts on control on your apps. The Office365Users function can also get some details, but not as flexible if you simply want to control it yourself.

    Assuming for the moment you do not have two users with the same names, here is one scenario - replace all in blue with your control names.

    Your List UserProfiles has these two fields NameUser (do not use UserName as it is a reserved word) and a Boolean field AdminAccess.

    The first thing you need to do on App OnStart is set a Global Variable for the User's name - this avoids delegation issues and server calls on User().FullName, so

    Set(vUserName,User().FullName)

    So now lookup the user's permissions (the Lower is for possible case-sensitive issues, although it generally works anyway).

    If(
     Lookup(
     UserProfiles,
     Lower(NameUser) = Lower(vUserName),
     AdminAccess
     ) = true,
     SortByColumns(
     BMPatientList, 
     "RoomNumber", 
     Ascending
     ), 
     SortByColumns(
     Filter(
     BMPatientList, 
     SupervisingHCP.DisplayName = varUser.FullName
     ), 
     "RoomNumber", 
     Ascending
     )
    )

     

    Please click Accept as solution 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 giving it Thumbs Up.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Based on the needs that you mentioned, please consider take a try with the following formula:

    SortByColumns(
     Filter(
     BMPatientList,
     If(
     varUser.FullName = "name1" || varUser.FullName = "name2" || varUser.FullName = "name3" || ...,
     true,
     SupervisingHCP.DisplayName = varUser.FullName
     )
     ), 
     "RoomNumber", 
     Ascending
    )

    Please take a try with above formula, then check if the issue is solved.

     

    In addition, you could also consider store these super users into a collection, then you just need to check if the current sign in user is existed in this collection, if true, display entire Gallery items:

    Set the OnStart property of App to following:

    ClearCollect(
     SuperUserCollection,
     "name1",
     "name2",
     "name3",
     ...
    )

    Modify your SortByColumns formula as below:

    SortByColumns(
     Filter(
     BMPatientList,
     If(
     varUser.FullName in SuperUserCollection.Value,
     true,
     SupervisingHCP.DisplayName = varUser.FullName
     )
     ), 
     "RoomNumber", 
     Ascending
    )

    then re-load your app (fire the OnStart property of App), check if the issue is solved.

     

    Best regards,

  • WarrenBelz Profile Picture
    156,536 Most Valuable Professional on at

    Hi @Anonymous ,

    A number of options for you here. Please tag whichever best suits you to continue the thread with.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz  If I use a boolean yes/no column in Sharepoint list, will that cause any errors with the formula you gave me that is checking true/false?

     

    Thank you.

  • WarrenBelz Profile Picture
    156,536 Most Valuable Professional on at

    Hi @Anonymous ,

    The underlying value of a SharePoint Yes/No column is true/false, so that formula was written for one of these.

     

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 347

#3
WarrenBelz Profile Picture

WarrenBelz 254 Most Valuable Professional

Last 30 days Overall leaderboard