cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Sytnax for Odata Order By

Is it possible to use multiple fields in the order by odata filter on a SharePoint get items action?  i.e. if I want to sort by Title Field, then Date Field as an example:

 

Title asc and Date asc

 

What is the correct way to structure that - it appears to be differen than the filter query sytax.

1 ACCEPTED SOLUTION

Accepted Solutions
v-micsh-msft
Community Support
Community Support

Hi @WiggityZwiggity,

 

The workable Sytnax for the order by should be:

Title asc, Date asc

Image reference:

59.PNG

 

The Sytnax usage is described here:

Use OData query operations in SharePoint REST requests

For orderby:

"

Use the $orderby query option to specify how to sort the items in your query return set. To sort by multiple fields, specify a comma-separated list of fields. You can also specify whether to sort the items in ascending or descending order by appending the asc or desc keyword to your query.

"

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-micsh-msft
Community Support
Community Support

Hi @WiggityZwiggity,

 

The workable Sytnax for the order by should be:

Title asc, Date asc

Image reference:

59.PNG

 

The Sytnax usage is described here:

Use OData query operations in SharePoint REST requests

For orderby:

"

Use the $orderby query option to specify how to sort the items in your query return set. To sort by multiple fields, specify a comma-separated list of fields. You can also specify whether to sort the items in ascending or descending order by appending the asc or desc keyword to your query.

"

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

That's awesome.  Is there a way to also apply this sorting on Unions?  i.e. if I am joining 2 arrays, and I want the combined results to sort?  the union(array1,array2) expression doesn't seem to allow for this.

Hi, thanks for your solution. I was wondering if i want to order number, power automate says this" !CKIxd!Syntax error at position 22 in 'Fecha Final_Modificada desc'. Ploc !
inner exception: !CKIxd!Syntax error at position 22 in 'Fecha Final_Modificada desc'. Ploc !
clientRequestId: 44c196fa-13c6-4fef-87f2-0877e196689e

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (3,211)