cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Sort or SortByCollumns with choise data type from a sharepoint list

Hello,

 

I am trying to make a galery that shows only part of the data of a Sharepoint list.

Those data have to be ordered, first by a collumn named "Etat_suivi", and then a collumn named "Date_previsionnelle".

On Sharepoint, the data types are "choise" for the "Etat_suivi" collumn and "date" for the "Date_previsionnelle" collumn.

 

The Filter fonction works with both data types but when I tried to use SortByCollumns, it worked on the "date" type but not on the "choise" type. The same problem appeared with the Sort function. I noticed that the data type of my "Etat_suivi" column is "complex" in PowerApps. The choises in "Etat_suivi" are on a text form.

 

Here is one of the formula I tried :

 

Sort(SortByCollumns(Filter(T_suivi_com;(Etat_suivi="Date à définir") Or (Etat_suivi="A publier") Or (Text(Date_reelle; "[$-fr]dd/mm/yyyy")= Text(Today(); "[$-fr]dd/mm/yyyy")));"Etat_suivi";["Date à définir";"A publier";"Publié"]);Date_previsionnelle)

 

Do you have a solution for me ?

 

Thank you.

 

7 REPLIES 7
mdevaney
Super User
Super User

@Anonymous 

When you say this what do you mean by "it did not work"? 

it worked on the "date" type but not on the "choise" type. The same problem appeared with the Sort function

 

Please provide an explanation and a screenshot of what the gallery looks like both when working and not working.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Anonymous
Not applicable

Here is a try with a "date" data type.

 

Capture_date.PNG

 

And this is a try with a "choise" data type.

 

Capture_liste.PNG

 

I have two error message on Galery.Items :

1-

impossible to sort on this type of expression

 

2- 

function "Sort" contains invalid arguments

Hi @Anonymous ,

I will throw something in here to possibly assist my colleague @mdevaney .

Firstly, I do not believe it is the Sort that is the problem - PowerApps is saying the expression you are trying to Sort is invalid (the Filter statement)
While noting that Date filters are not delegable (whether they are turned into text or not), I was involved in another post today involving a filter requiring a date to equal another date. Could the item below  possibly be your issue here?DateSort.png

There is more than one way to do this of course, but I know when I struck the problem a while ago, the code as per the post works.

Also you might try using || instead of Or - and you don't need all the brackets if the arguments are all of the same type, though I am not sure this will make any difference.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

 

 

Anonymous
Not applicable

Hello Warren,

 

First, thank you to work on my problem.I do not have problems with the date

 

I do not have any problem to sort the date type. It is with the list type that I have a problem. I showed the sort function with a date type to show that it with another format.

 

The filter function alone woks perfectly, I tested it. I think that it is the second argument (Etat_suivi) that is a problem.

The list type data do not function like string data in PowerApps, to be able to use the filter function, I had to add “.Value” to the name of the column for my filter function.

 

I noticed that the sort function worked with the “.Value” on Etat_suivi :

 


Sort(Filter(T_suivi_com;(Etat_suivi.Value="Date à définir") Or (Etat_suivi.Value="A publier") Or (Text(Date_reelle; "[$-fr]dd/mm/yyyy")= Text(Today(); "[$-fr]dd/mm/yyyy"))); Etat_suivi.Value)

However, I did not succeed to make it work the SortByCollumns function.

 

I tried the followings formulas without success:

 


SortByCollumns((Filter(T_suivi_com;(Etat_suivi.Value="Date à définir") Or (Etat_suivi.Value="A publier") Or (Text(Date_reelle; "[$-fr]dd/mm/yyyy")= Text(Today(); "[$-fr]dd/mm/yyyy"))); Etat_suivi.Value))

 


SortByCollumns((Filter(T_suivi_com;(Etat_suivi.Value="Date à définir") Or (Etat_suivi.Value="A publier") Or (Text(Date_reelle; "[$-fr]dd/mm/yyyy")= Text(Today(); "[$-fr]dd/mm/yyyy"))); "Etat_suivi.Value"))

 


SortByCollumns((Filter(T_suivi_com;(Etat_suivi.Value="Date à définir") Or (Etat_suivi.Value="A publier") Or (Text(Date_reelle; "[$-fr]dd/mm/yyyy")= Text(Today(); "[$-fr]dd/mm/yyyy"))); "Etat_suivi"))

 

I need to use the SortByCollumns function because the order I want to use for my sorting is neither ascending nor descending.

 

Do you have any solution?

 

Thanks again for your reply.

WarrenBelz
Super User
Super User

Hello @Anonymous ,

I was just throwing some ideas to help @mdevaney ,

I have tagged him above to continue with this.

@Anonymous 

First, I noticed that you mispelled SortByColumns as SortByCollumns.  Please make a correction.

 

SortByColumns((Filter(T_suivi_com;(Etat_suivi.Value="Date à définir") Or (Etat_suivi.Value="A publier") Or (Text(Date_reelle; "[$-fr]dd/mm/yyyy")= Text(Today(); "[$-fr]dd/mm/yyyy"))); Etat_suivi.Value))

 

Secondly, you said "I need to use the SortByColumns function because the order I want to use for my sorting is neither ascending nor descending."  My question is what do you mean you want to by neither ascending or descending?  From what I understand that is what sorting means.  Please give an example.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."  

Anonymous
Not applicable

Hello @mdevaney 

 

Thank you to offer me a solution. Unfortunately it didn't worked.

 

For your second observation, I want to sort in that order ("Date à définir" => "A publier" => "Publié") which is neither a A to Z sorting nor a Z to A sorting.

 

My client decided that the sorting was not a demand critical enough to spend so much time so I'll stop searching a solution from now.

 

Howerver, I will be intrested in the solution if anyone finds it.

 

Anyway, thank you @mdevaney and @WarrenBelz for your work on my problem.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,835)