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

Community site session details

Session Id : V5kxhhi/Fl99Kns6ho0VTh
Power Apps - Building Power Apps
Answered

Need better understanding of how the Default Sort button works and if it can be changed

Like (1) ShareShare
ReportReport
Posted on 29 Dec 2023 19:37:33 by 99

Still struggling to understand all of the unique ways this PowerApp thing works.  I have restarted my project way too many times out of frustration.  I have a simple SharePoint list.  I now understand there is a required TITLE field however I am not going to populate it with anything.  It appears that when using the wizard to build the initial app, the sort button (the up and down arrows) use that TITLE field to sort the various records.  Can you change this to sort on a different field and still have the little button control it?  It also seems that the default SEARCH field also uses this same field but I do not understand enough about yet to change it.  Any suggestions on how to better learn how these canned features functions?

Categories:
I have the same question (0)
  • spectraflame Profile Picture
    99 on 05 Jan 2024 at 14:05:09
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    Appreciate your patience with me and my lack of understanding PowerApps.  On the surface it looks simple, but I have learned that it is more powerful and useful than I initially thought.

  • Verified answer
    Pstork1 Profile Picture
    67,987 Most Valuable Professional on 05 Jan 2024 at 14:01:25
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    Let me handle it in reverse order.

    1) Unless you want to filter or sort on Title you don't need to mention that at all.

    2) The way you have the values set right now you are sorting and filtering on Department. You don't need to do both. If you filter on Department then the only records shown in the gallery will be for that Department. In that case Sort doesn't mean anything because they are all the same.  So your second line of code is the correct one. It filters based on Department and then Sorts based on Inspection Date.

  • spectraflame Profile Picture
    99 on 04 Jan 2024 at 20:22:52
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    Not sure if this was what you were suggesting but The Gallery ITEMS formula is currently set to:  Sort(Filter([@'VEHICLE INSPECTIONS'], StartsWith(DEPARTMENT.Value, SearchInput1.Text)), DEPARTMENT.Value, If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

     

    I am assuming since the sort button within the Gallery is set to:  UpdateContext({SortDescending1: !SortDescending1}) that what ever

     

    This allows the list to be narrowed down by department name.  If I it to:  Sort(Filter([@'VEHICLE INSPECTIONS'], StartsWith(DEPARTMENT.Value, SearchInput1.Text)), INSPECTION_DATE, If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

     

    The filter then allows me to narrow it down by department and then use the sort button to sort by date.

     

    Does the Title Field have any bearing on any of this?

  • Pstork1 Profile Picture
    67,987 Most Valuable Professional on 03 Jan 2024 at 22:28:13
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    By outer sort I mean the function on the outside versus the function on the inside.  If you remove all the extra conditions etc. the relationship of the functions looks like this.

    Sort(Filter()). So the Filter is done first and the Sort sorts the results of the filter.  So the Sort is outside the Filter.  But looking back at the code you are using Sorting on Department when you are also filtering out other departments doesn't really make sense.  So just replace the value you are sorting on with the Inspection_Date field.

  • spectraflame Profile Picture
    99 on 03 Jan 2024 at 20:48:42
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    When you say "Outer Sort" are you referring to the Up/Down arrow in the Quick Action Bar?  If so, it is currently set to:  UpdateContext({SortDescending1: !SortDescending1}) for the OnSelect formula.  So that formula would need to be updated to include my Inspection_Date field?

  • Pstork1 Profile Picture
    67,987 Most Valuable Professional on 03 Jan 2024 at 19:03:38
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    If you filter by Department inside the sort then the only records you will get will be for that department. Then the Sort on the outside will sort those records.  So if the outer sort is by modified date descending then the most recent record from that department will be on top.  

  • spectraflame Profile Picture
    99 on 03 Jan 2024 at 15:24:46
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    So is there a way to use the same SORT code and use a secondary sort field to put the most recent record at the top?  If I have 12 records per department, if I searched for the Electric department, it would be useful to have the most recent inspection at the top of the list.

  • Pstork1 Profile Picture
    67,987 Most Valuable Professional on 03 Jan 2024 at 14:21:22
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    No, you don't need a special column. Just use Sort() instead of SortByColumns() and make sure you reference the value property as I've shown in the code in my reply above.

  • spectraflame Profile Picture
    99 on 03 Jan 2024 at 13:50:00
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    So would you recommend creating a single text column that would duplicate/copy the value from the Choice Box to simplify the sort or filter?

  • Pstork1 Profile Picture
    67,987 Most Valuable Professional on 29 Dec 2023 at 21:54:44
    Re: Need better understanding of how the Default Sort button works and if it can be changed

    OK, the problem is that Department is a choice column. Choice columns are not simple text, they are a complex object that has both and index and a value.  So to search on them you need to access the Value property of the Choice column.

     

    that also causes a problem with SortByColumns since its a complex column. So you either need to AddColumns() to create a single text column with the value or switch to Sort().

     

    Here's the final code using Sort() and the Department.Value instead of Department.

    Sort(Filter([@'VEHICLE INSPECTIONS'], StartsWith(DEPARTMENT.Value, TextSearchBox1.Text)), DEPARTMENT.Value, If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 892 Most Valuable Professional

#2
Power Apps 1919 Profile Picture

Power Apps 1919 356

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 310 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading complete