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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sort by nested columns...
Power Apps
Answered

Sort by nested columns with custom ordering

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi my collection is a Table with records and nested records.

 

Ie. MyTasks._links.priority.title, where _links and priority are also tables, and title is a record with values or either high, medium or low.

 

How do i sort by Status with a custom order ["high","medium","low"]

 

I have tried 

 

SortByColumns(MyTasks,"_links.priority.title",["high","medium","low"]) but this doesn't work.

Categories:
I have the same question (0)
  • Vijay Tailor Profile Picture
    2,961 on at

    Hi @Anonymous ,

    You can use like below - 

    SortByColumns(MyTasks,"_links.priority","Title",Ascending)

    Thanks, 

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@ajhstn,

    Based on the issue that you mentioned, do you want to sort a custom order in a nested table?

    Could you please share a bit more about your collection?

    In general, we sort using the following formula:

     

    SortByColumns( Table, ColumnName, SortOrderTable )

     

    You could not directly sort a nested table, you should add a column to store the "_links.priority.title" values and sort based on this added column.

    I have a test on my side, please take a try as below.

    I create a nested collection as below:

     

    ClearCollect(
     MyTasks,
     {
     ID: 1,
     _links: {priority: {title: "high"}}
     },
     {
     ID: 2,
     _links: {priority: {title: "low"}}
     },
     {
     ID: 3,
     _links: {priority: {title: "medium"}}
     }
    )

     

    Add a Gallery to display this collection. To sort the custom order, set the Items property of the Gallery as below:

     

    SortByColumns(
     AddColumns(
     MyTasks,
     "SortColumn",
     _links.priority.title
     ),
     "SortColumn",
     [
     "high",
     "medium",
     "low"
     ]
    )

     

    100903.png

    Hope this could help you.

    Best Regards,

    Qi

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @VijayTailor that unfortunately doesn't work, it says "_links.priority" doesn't exist, but it actually does.  

     

    Screen Shot 2020-10-09 at 20.40.06.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-qiaqi-msft amazing, that did it and i learned something new!  thank you

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard