cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Antonioclk
Helper IV
Helper IV

Sorting by a Person Type Column from Sharepoint List

Hello, i have an app made with a gallery, a search bar and a sort icon.


The gallery is loaded with a SharePoint connector.
The sharepoint list has a Person Type column called User.
The gallery shows names and surname using User.DisplayName.

 

I'd like to be able to click on the sort icon and have the gallery sorted by the name or surname of the user.

how can i do that? i read that sortbycolumn function doesn't work with special columns.

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Antonioclk ,

One of the (many) reasons I do not use Person columns - this is not Delegable (nor can you make it so)

Sort(
   AddColumns(
      SPList,
      "PersonSort",
      YourPersonColumn.DisplayName
   ),
   PersonSort,
   If(
      SortDescending, 
      Descending, 
      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.

Visit my blog Practical Power Apps

View solution in original post

6 REPLIES 6
WarrenBelz
Super User
Super User

Hi @Antonioclk ,

One of the (many) reasons I do not use Person columns - this is not Delegable (nor can you make it so)

Sort(
   AddColumns(
      SPList,
      "PersonSort",
      YourPersonColumn.DisplayName
   ),
   PersonSort,
   If(
      SortDescending, 
      Descending, 
      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.

Visit my blog Practical Power Apps

Thank you so much, i tried exactly this but when i click on the filter icon it does nothing, like it wasn't linked with the gallery... how can it be? 
the code is written in the onSelect property of the icon. should i wrap it into an UpdateContext? 

 

Your blog is very interested, i favorited it 😉 

Hi @Antonioclk ,

Neither, the code would be used for the Items of a Gallery, Drop-down or Combo Box.

 

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.

Visit my blog Practical Power Apps

oh ok, and how can i reverse the order (ascending, descending) by clicking on the icon?

i wrote this in my gallery Items property 

 

 

Filter(
    Search(
        AddColumns(
            MyData,
            "UserName",
            User.DisplayName
        ),
        SearchBar.Text,
        "UserName", "Phone"

    ),
    If(
        IsEmpty(sportList.SelectedItems),
        true,
        Sport in sportList.SelectedItems
    ),
    If(SortDescending, Descending, Ascending))
)

 

 

and in the sort icon onSelect i wrote

 

 

UpdateContext({SortDescending: !SortDescending})

 

 

 

but it's not working, when i click the icon it doesnt happen anything

@Antonioclk ,

Please see update post.

 

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.

Visit my blog Practical Power Apps

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (2,213)