cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
saturation
Resolver I
Resolver I

SortColumn not working on Lookup

I'm trying to set SortColumn on a lookup column on my gallery item. State is the name of the lookup entity.

 

Set(SortColumn, "State");UpdateContext({SortColumn: "State", SortDescending: !SortDescending})
 
I've also tried State.Value, State.Name etc (in double quotes)
 
My sorting works on text fields using the same syntax. Can someone help here? 
10 REPLIES 10

Hi @saturation ,

Have you taken a try with the solution I provided above?

 

Currently, within PowerApps, you could not specify Complex type column (e.g. LookUp, Choice, ... etc) as Sort column within the SortByColumns function.

 

As an alternative solution, I think the Sort function could achieve your needs. In addition, you could not specify variable as Sort column within the Sort function.

 

Please consider take a try with above Sort function I provided, then check if the issue is solved:

Sort(
     Filter(
             'MyData',
             ....
     ),
     If(                                // choose different Sort formula based on the SortField variable value
        SortField = "State",
        State.'Primary Name',            // 'Primary Column' represents the child property under the State LookUp field
        SortField = "Column1",
        Column1,
        ....
     )
     ,
     If(
         SortDescending,
         SortOrder.Ascending,
         SortOrder.Descending
      )
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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