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

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,564)