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 / How to Create Toggle B...
Power Apps
Answered

How to Create Toggle Buttons for Gallery Using SharePoint Multiple Select People Column

(1) ShareShare
ReportReport
Posted on by 108

Hi all. I'm creating an app that allows users to view, edit, and submit request forms. The app contains multiple screens but for this question, I'm only focused on what happens on one screen called My Requests. From this screen users view requests either they or everyone on the team created.

This screen is made up of a Gallery, an Edit Form set to View mode, and two buttons above the Gallery that, when toggled, allows the user to view only the requests they created (View My Requests) or view everyone's requests (View All Requests).  When the View My Requests button is not visible, the View All Requests button is and the Gallery shows only the requests created by the user. And vice-verse, when the View All Requests button is visible, the View My Requests button is not and the Gallery shows all requests created by the team. The code that makes this possible is...

Gallery (Items)

If(!'Btn-ViewMyRequests', Filter('SharePoint List Name', 'Submitted by'.DisplayName Or'Assigned to'.DisplayName = Office365Users.MyProfileV2().displayName), 'SharePoint List Name')

This code successfully compares the names in the 'Submitted by' and 'Assigned to' columns from my SharePoint list with the user and toggles the view accordingly. However, this code only works when both columns allow for a single selection. I need the code to work when both columns allow for multiple selections. But as it is now, when the columns are set to allow multiple selections the Gallery displays blank items with several errors. How do I get the code to work and the gallery to display items when both columns are set to allow multiple selections in SharePoint? Do I need to use the Choices or Concat functions? Or use an entirely different function? Thanks all.

Note: The data in both columns in SharePoint are people/group choices and my app is connected to the Office 365 Users Connector. 

Categories:
  • Giraldoj Profile Picture
    1,005 Super User 2026 Season 2 on at

    Hi @powerpepper 

     

    you need to modify the way you handle the comparisons for the 'Submitted by' and 'Assigned to' fields, which are now allowing multiple selections. Here’s how you can adapt your code to work with multi-select fields:

    1. Use the ForAll and Filter functions:

      Since both columns now allow multiple selections, you need to loop through the selected values in these columns to check if the current user is one of the selected users.
    2. Use the IsBlank and LookUp functions:

      To determine if the current user is in the selected users, you can use IsBlank and LookUp functions.

    Here’s how you can update your Gallery Items property:

     

     

     

    If(
     !'Btn-ViewMyRequests',
     Filter(
     'SharePoint List Name',
     Not(IsBlank(LookUp('Submitted by', Value.DisplayName = Office365Users.MyProfileV2().displayName))) || 
     Not(IsBlank(LookUp('Assigned to', Value.DisplayName = Office365Users.MyProfileV2().displayName)))
     ),
     'SharePoint List Name'
    )

     


    Note: If your dataset its too large you are going to face delegation warnings because you are using filter directly in your datasource and some of them does not allow delegation, my recommendation will be import you whole dataset into a collection first and then apply the required fitler.

     

    If my response resolved your issue, please feel free to mark it as the solution by clicking accept it as a solution. 

    If you liked my solution, please give it a thumbs up
    This helps others find the answer more easily.

    Connect with me: LinkedIn 

  • powerpepper Profile Picture
    108 on at

    Thanks for responding @Giraldoj. At this time my dataset is within app limits so I'm not concerned about the delegation warnings yet, but will keep your recommendation in mind. In trying your solution I received these errors for both lines of code...

     

    Gallery (Items)

     

    If(
     !'Btn-ViewMyRequests',
     Filter(
     'SharePoint List Name',
     Not(IsBlank(LookUp('Submitted by', Value.DisplayName = Office365Users.MyProfileV2().displayName))) || 
     Not(IsBlank(LookUp('Assigned to', Value.DisplayName = Office365Users.MyProfileV2().displayName)))
     ),
     'SharePoint List Name'
    )

     

    Not is underlined yellow with the error "The Not operation is not supported by this connector." Lookup is underlined red with the error "The function Lookup has some invalid arguments." 'Submitted by'/'Assigned to' is underlined  red with the error "Invalid argument type." Value.DisplayName = is underlined red with the error "Name isn't valid. 'Value' is not recognized."

     

    Is this an overarching formatting issue where the app can't recognize the data type referenced between the code and my dataset? The data for both columns in my SharePoint list are people/group choices rather than self-typed choices/strings/numbers. I've tried removing Value form the operation and retyping the code as 'Submitted by'.DisplayName (because, so far, that's how it's written everywhere else in my code and the app accepts it with no issues/warnings), but with no success. 

  • Giraldoj Profile Picture
    1,005 Super User 2026 Season 2 on at

    Hi @powerpepper 

     

    I had some errors in my previous answer, lets take a different approach

     

    The current issue arises because the Lookup and Not functions are not supported in the way I was trying to use them, and there are issues with the data types. Instead, lets use a combination of ForAll, Filter, and CountIf to ensure that the gallery displays items that meet all criteria specified by the selections in the ComboBox.

    First, ensure you have a variable to toggle between "View My Requests" and "View All Requests". Let's assume you have a variable called showMyRequests.

    Here’s how to update your Gallery’s Items property:

     

     

    If(
     !showMyRequests,
     Filter(
     'SharePoint List Name',
     CountIf('Submitted by', DisplayName = Office365Users.MyProfileV2().displayName) > 0 || 
     CountIf('Assigned to', DisplayName = Office365Users.MyProfileV2().displayName) > 0
     ),
     'SharePoint List Name'
    )

     

     

    1. Filter: Filters the SharePoint list based on whether the current user is in the 'Submitted by' or 'Assigned to' fields.
    2. CountIf: Checks if the current user is included in the multi-select fields. CountIf returns the count of matches, and we check if this count is greater than 0.
    3. showMyRequests: A boolean variable used to toggle between showing requests by the current user or all requests.

    If your dataset grows, you may encounter delegation warnings. Power Apps has limits on the amount of data that can be processed client-side, and not all functions are delegable. For now, as your dataset is within limits, this approach should work. In the future, consider loading your data into a collection first and then applying filters on the collection to avoid delegation issues.

    If you want to prepare for larger datasets, you can load your data into a collection:

    1. OnVisible Property of the Screen:

      ClearCollect(allRequests, 'SharePoint List Name');
    2. Gallery Items Property:

     

    If(
     !showMyRequests,
     Filter(
     allRequests,
     CountIf('Submitted by', DisplayName = Office365Users.MyProfileV2().displayName) > 0 || 
     CountIf('Assigned to', DisplayName = Office365Users.MyProfileV2().displayName) > 0
     ),
     allRequests
    )

     

     

    This way, you can handle larger datasets more efficiently.

  • powerpepper Profile Picture
    108 on at

    Hi @Giraldoj. Thanks again for responding and even walking me through a different solution. Unfortunately, I haven't had any success with it, but will keep playing around with it. If anything changes I'll reply back or repost here.

  • Verified answer
    powerpepper Profile Picture
    108 on at
    Creating Toggles on Gallery with Multiple Selection SharePoint Columns

    Items Involved
    1. View All (Button)
    2. View My (Button)
    3. Gallery (Connected to SharePoint List)
    4. Add Office 365 Users Connector

    Settings on View All Button
    On Select
    UpdateContext({BttnViewMy:true})
    Visible
    !BttnViewMy
    Code Meaning:  When the View All button is clicked, display the View My button. The View All button is not visible when the View My button is visible. ​​​​​​​
     
    Settings on View My Button
    On Select
    UpdateContext({BttnViewMy: !BttnViewMy}); 
    
    UpdateContext({BttnViewAll: true})
    Visible
    BttnViewMy
    Code Meaning: When the View My button is clicked, display the View All button. The View My button is not visible when the View All button is visible.
     
    Settings for Gallery
    Items
    If(
        !BttnViewMy,
        Filter(
            Sort(
                'SharePoint List Name',
                'Due Date',
                SortOrder.Descending
            ),
            'Submitted By'.DisplayName = Office365Users.MyProfileV2().displayName
        ),
        'SharePoint List Name'
    )
    Code Meaning: When the View My button is clicked, the Gallery will show only results the user submitted. Results will be sorted by 'Due Date' in descending order. When the View All button is clicked, the gallery will show all results in the SharePoint List.  'Due Date' is the column in SharePoint I wanted to sort the items by. This can be whatever you named your column. 'Submitted By' is the column in SharePoint I wanted to compare the user with and can be whatever you named your column. Make sure you choose the right data type! For example if you want to compare the user's email, then the code will read 'Submitted By'.Email= Office365Users.MyProfileV2().mail.    

    With the code above, when toggling to View All, the Gallery will sort the results in whatever default order your SharePoint List is in. To change the sorting, replace the last code with the appropriate sort function. I wanted my results to be in the same descending order when the View My button is clicked, so I added the descending sort function to the last bit of code. The final code for my Gallery looks like this:
     
    If(
        !TestBttnViewMy,
        Filter(
            Sort(
                '[Test]CompRequests',
                'Due Date',
                SortOrder.Descending
            ),
            'HRBP Name'.Email = Office365Users.MyProfileV2().mail
        ),
        Sort(
            '[Test]CompRequests',
            'Due Date',
            SortOrder.Descending
        )
    )
    Hope this helps anyone else struggling with this!
     

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