cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
juandmurray
Frequent Visitor

SortbyColumns does not allow other columns to set the order of the list

Hi!

I am trying to use the SortByColumns function to sort the list in the app based on the priority of each item, but the function only allows me to sort by the title of the items.

I have no problems if I use the following function (I am also filtering the list items that area already completed):

SortByColumns(Filter(MyListName; StartsWith(Title; TextSearchBox1.Text) && Estado.Value <> "Completado" );"Title"; If(SortDescending1; Descending; Ascending))

 

But when I try to filter based on the Priority, it says it has an error but it doesn't specify which error it is. I only change the "Title" for "Priority".

SortByColumns(Filter(MyListName; StartsWith(Title; TextSearchBox1.Text) && Estado.Value <> "Completado" );"Priority"; If(SortDescending1; Descending; Ascending))

 

In my sharepointlist, the column is named "Prioridad" (it does not work with that name either), but in the sharepoint list I found that the original name of the column was Priority:

https://sitename/teams/MyListName/_layouts/15/FldEdit.aspx?List=%7B9937ACAF%2DE2C4%2D465D%2DA325%2D8EE5728BA612%7D&Field=Priority

 

does anyone know how to make it work with anything other than the Title?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@juandmurray 

What kind of column is Priority?

If it is a choice column, then you need to alter your formula to account for that.  

SortByColumns will only accept "real" names of columns (as you found in the list settings) and only simply types (text, number, etc).

 

So, if your Priority is a choice column, then this will give you the results you would like:

SortByColumns(
    AddColumns(
        Filter(MyListName; 
            StartsWith(Title; TextSearchBox1.Text) && Estado.Value <> "Completado" 
        );
        "_priority"; Priority.Value
    );
    "_priority"; 
    If(SortDescending1; Descending; Ascending)
)

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@juandmurray 

What kind of column is Priority?

If it is a choice column, then you need to alter your formula to account for that.  

SortByColumns will only accept "real" names of columns (as you found in the list settings) and only simply types (text, number, etc).

 

So, if your Priority is a choice column, then this will give you the results you would like:

SortByColumns(
    AddColumns(
        Filter(MyListName; 
            StartsWith(Title; TextSearchBox1.Text) && Estado.Value <> "Completado" 
        );
        "_priority"; Priority.Value
    );
    "_priority"; 
    If(SortDescending1; Descending; Ascending)
)

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

THANK YOU!!!! Yes, that was the solution to my problem!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,885)