web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problem with sorting L...
Power Apps
Answered

Problem with sorting Lookup Column

(0) ShareShare
ReportReport
Posted on by 8

Hello-

I'm building a basic app that is based on data from a SharePoint list ("Customer Location List"). One column in the list is a "lookup" column ("Customer Name"), pulling data from another list. 

 

My problem is sorting. Here's what I have for the sort function. I know "Title" isn't right. I have a label within the gallery that displays the customer name (ThisItem.'Customer Name'.Value). But I can't figure out what to change "Title" to in order to make the sort work. 

SortByColumns(Filter([@'Customer Location List'],StartsWith('Customer Name'.Value,TextSearchBox1.Text)),"Title",If(SortDescending1,Descending,Ascending))

 

I'm new to this, so go easy on me. 😃

 

Thanks!

James

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    Try:

    Sort(Filter([@'Customer Location List'],StartsWith('Customer Name'.Value,TextSearchBox1.Text)),Title,If(SortDescending1,Descending,Ascending))

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • JimmyKY Profile Picture
    8 on at

    Sorry, maybe my question wasn't 100% clear. 

     

    "Title" is the default value for the sort function. I want to sort based on Customer Name'.Value.

     

    I want to replace "Title" with Customer Name.Value. When I do (as shown below) it throws "Name isn't valid. The identifier isn't recognized".

    SortByColumns(Filter([@'Customer Location List'],StartsWith('Customer Name'.Value,TextSearchBox1.Text)),Customer_x0020_Name'.Value,If(SortDescending1,Descending,Ascending))

     

    I'm not sure how to get the sort ascending/descending to work with Customer Name.Value?

     

    Thanks in advance,

    James

  • JimmyKY Profile Picture
    8 on at

    I should add: I understand that the column is a "lookup" column, so it's a structure, not a value. Can you sort ascending/descending on a structure? I would have thought "value" would have done it, but it does not. 

  • Verified answer
    eka24 Profile Picture
    20,923 on at

    Have you tried Sort:

    Sort(Filter([@'Customer Location List'],StartsWith('Customer Name'.Value,TextSearchBox1.Text)),'Customer_x0020_Name'.Value,If(SortDescending1,Descending,Ascending))

     

    Or

    For SortByColumns, the column being sorted should be in quotes " "

    Try and do that

     

  • JimmyKY Profile Picture
    8 on at

    That worked, thank you!!!

  • alrezac Profile Picture
    on at

    Hi,

     

    It looks like you were able to get an answer to your issue that you were having. I just wanted to pop in with a little more information if you would like to learn more. Feel free to take a look.

     

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-sort

     

    Regards,

     

    Alex

     

    -------

     

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard