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.

View solution in original post

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,308)