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 a gallery by...
Power Apps
Unanswered

Filtering a gallery by a person or group column in a sharepoint list

(0) ShareShare
ReportReport
Posted on by 10

Hello, 

 

I am creating an app that is connected to a sharepoint list where people submit requests, these requests are then assigned to a person from my department. Their profile is pulled from office365. I have tried many ways to be able to sort the gallery by person and all have failed unfortunately. Here is my current formula for the gallery: 

SortByColumns(
Filter(
'Feedback Tool 2022',
(Dropdown2.Selected.Value="-" || 'Status'.Value=Dropdown2.Selected.Value) &&
(IsBlank('Rep') || StartsWith('Rep'.DisplayName, Dropdown1.Selected.Value))
),
"ID",
SortOrder.Descending
)

 

Please let me know what additional information you may need to help me complete this, thank you!

Categories:
  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @haileym - I am not clear on what you have in the Items property of Dropdown1, but nevertheless, will need to use the AddColumns function to create a "virtual" column which is populated with the display name attribute from your Rep column. You can then run the Sort function on that virtual column. For example:

     

    SortByColumns(
     Filter(
     AddColumns(
     'Feedback Tool 2022',
     "RepDisplayName",
     Rep.DisplayName
     ),
     Dropdown2.Selected.Value = "-" || Status.Value = Dropdown2.Selected.Value,
     Len(Dropdown1.Selected.Value) = 0 || StartsWith(
     Rep.DisplayName,
     Dropdown1.Selected.Value
     )
     ),
     "RepDisplayName",
     SortOrder.Descending
    )

     

    Note that the AddColumns function is not delegable. However, if you can be certain that filtering on the Status Choice field will always return less than 2000 records, I would suggest using the following pattern instead:

     

    With(
     {
     _prefiltered_data: Filter(
     'Feedback Tool 2022',
     Dropdown2.Selected.Value = "-" || Status.Value = Dropdown2.Selected.Value
     )
     },
     SortByColumns(
     Filter(
     AddColumns(
     _prefiltered_data,
     "RepDisplayName",
     Rep.DisplayName
     ),
     Len(Dropdown1.Selected.Value) = 0 || StartsWith(
     Rep.DisplayName,
     Dropdown1.Selected.Value
     )
     ),
     "RepDisplayName",
     SortOrder.Descending
     )
    )
    
  • haileym Profile Picture
    10 on at

    Hi Imran-Ami, 

     

    I received the following errors when I used this code: 

    1. Invalid argument type (table) 

    2. the functions startswith has some invalid arguments 

    3. cannot sort on the expression type 

    4. the function sortbycolumns has some invalid arguments 

     

    When I type Rep. there is no prepopulated option. "DisplayName"

    does not show up. 

     

    For clarity dropdown1 has display names manually entered in alphabetical order by last name. For example: Items = ["Doe, John", "Presley, Elvis", "Williams, Serena"]

     

    Thank you

  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    hey @haileym 

     

    can you try this please:

     

    ClearCollect(
     ColFeedback,
     AddColumns(
     'Feedback Tool 2022',
     "RepName", 'Rep'.DisplayName
     )
    );
    
    // Then use this collection in your gallery's Items property
    SortByColumns(
     Filter(
     ColFeedback,
     (Dropdown2.Selected.Value="-" || 'Status'.Value=Dropdown2.Selected.Value) &&
     (IsBlank('RepName') || StartsWith('RepName', Dropdown1.Selected.Value))
     ),
     "RepName",
     SortOrder.Ascending
    )
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @haileym - in your original code, you have an option to select the "DisplayName" attribute when you type "Ryp." This would suggest your Rep field is a SharePoint people field.

     

    Is that not the case?

     

    Regarding the suggestion offered by @mmbr1606 - I would not recommend creating a Collection. This is unnecessary and more importantly, it will slow down your app.

  • IAmIntractable Profile Picture
    280 on at

    I see that a solution using With and also clearcollect is presented. Best I can tell the With creates a temporary data structure that is discarded when the With is complete, vs. casting a new collection with is always using up memory. Is there are other efficiency achieved by using With?

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard