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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,348)