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 / "SortOrder.Descending"...
Power Apps
Answered

"SortOrder.Descending" syntax error in my formula

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,
I have some difficulties when I write this formula in my "Browse screen" screen, I would just like to use the SORTBYCOLUMNS function, with SORTORDER.DESCENDING. Because in fact I want my files to appear from the most recent to the oldest. But I can’t find the right writing syntax...
My current formula is:

 

************************************************************************************************

SortByColumns(Filter(MY SHAREPOINT LIST;Agence.Value = Dropdown2.SelectedText.Value; Or(
StartsWith(Commune;TextSearchBox1_1.Text);
StartsWith(Enquêteur;TextSearchBox1_1.Text);
StartsWith(Text(ID);TextSearchBox1_1.Text);
StartsWith(Text('Nom de la voie');TextSearchBox1_1.Text);
StartsWith(Text('Nom du demandeur du contrôle');TextSearchBox1_1.Text);
StartsWith('Code INSEE Commune'&"-"&(ID);TextSearchBox1_1.Text);
StartsWith('Numéro de voie';TextSearchBox1_1.Text)));"ID";
If(SortDescending1;Descending;Ascending))

************************************************************************************************

 

And i try this formula, but it doesn't work....

************************************************************************************************

SortByColumns(Filter(MY SHAREPOINT LIST;Agence.Value = Dropdown2.SelectedText.Value; Or(
StartsWith(Commune;TextSearchBox1_1.Text);
StartsWith(Enquêteur;TextSearchBox1_1.Text);
StartsWith(Text(ID);TextSearchBox1_1.Text);
StartsWith(Text('Nom de la voie');TextSearchBox1_1.Text);
StartsWith(Text('Nom du demandeur du contrôle');TextSearchBox1_1.Text);
StartsWith('Code INSEE Commune'&"-"&(ID);TextSearchBox1_1.Text);
StartsWith('Numéro de voie';TextSearchBox1_1.Text)));"ID";SortOrder.Descending;If(SortDescending1;Descending;Ascending))

************************************************************************************************

 

Have you any suggestions please ?

Thanks a lot

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,007 Most Valuable Professional on at

    Hi @Anonymous ,

    You have two sort parameters - you only need one

    SortByColumns(
     Filter(
     MY SHAREPOINT LIST;
     Agence.Value = Dropdown2.SelectedText.Value &&
     (
     StartsWith(Commune;TextSearchBox1_1.Text) ||
     StartsWith(Enquêteur;TextSearchBox1_1.Text) ||
     StartsWith(Text(ID);TextSearchBox1_1.Text) ||
     StartsWith(Text('Nom de la voie');TextSearchBox1_1.Text) ||
     StartsWith(Text('Nom du demandeur du contrôle');TextSearchBox1_1.Text) ||
     StartsWith('Code INSEE Commune'&"-"&(ID);TextSearchBox1_1.Text) ||
     StartsWith('Numéro de voie';TextSearchBox1_1.Text)
     )
     );
     "ID";
     Descending
    )

     

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for your proposition,

    but if i write your formula,

    i don't have this text : 

    If(SortDescending1;Descending;Ascending))

     

    so the BUTTON "SortDescending1" like in the picture doesn't work.

    This is the ON SELECT formula for this button : 
    UpdateContext({SortDescending1: !SortDescending1})

    bouttonPOWERAPPS.PNG
  • WarrenBelz Profile Picture
    156,007 Most Valuable Professional on at

    @Anonymous ,

    Yes, but your original code will sort by ID descending (which is what you asked for) when you push the button (and back ascending when you push it again).

    What exactly are you trying to achieve?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz 

     

    Thank you for your answer,
    in fact, I wish that by default on the BROWSECREEN my files appear in a DESCENDING way, from the most recent to the oldest, but I also want that when we click on the button, we can still change the order in ASCENDING or DESCEDING and vice versa

  • Verified answer
    WarrenBelz Profile Picture
    156,007 Most Valuable Professional on at

    @Anonymous ,

    Just reverse the logic on the button (although you might also want to rename the Variable to SortAscending to avoid confusion)

    SortByColumns(
     Filter(
     MY SHAREPOINT LIST;
     Agence.Value = Dropdown2.SelectedText.Value &&
     (
     StartsWith(Commune;TextSearchBox1_1.Text) ||
     StartsWith(Enquêteur;TextSearchBox1_1.Text) ||
     StartsWith(Text(ID);TextSearchBox1_1.Text) ||
     StartsWith(Text('Nom de la voie');TextSearchBox1_1.Text) ||
     StartsWith(Text('Nom du demandeur du contrôle');TextSearchBox1_1.Text) ||
     StartsWith('Code INSEE Commune'&"-"&(ID);TextSearchBox1_1.Text) ||
     StartsWith('Numéro de voie';TextSearchBox1_1.Text)
     )
     );
     "ID";
     If(
     SortDescending1;
     Ascending;
     Descending
     )
    )

     

    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.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz  thanks a lot ! It works... 

  • sid95 Profile Picture
    2 on at

    SortByColumns('Floor Opening',OpeningNumber_Column1,SortOrder.Descending);

     

     

    i'm getting an error here, someone assist me please

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

#2
11manish Profile Picture

11manish 193

#3
Valantis Profile Picture

Valantis 138

Last 30 days Overall leaderboard