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 / SortByColumns on a sha...
Power Apps
Answered

SortByColumns on a sharepoint choice field

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm trying to sort a gallery using two columns. One column is a text field and the other is a combobox/choice field. (single selection).

 

SortByColumns(Filter(DataSource,***filter parameters here****),"SortColumn1",Ascending,"SortComboColumn2",Acending)


this throws a "Cannot sort on the expression type".

 

I tried this as well and I can't seem to convert this column to a compatible type.

SortByColumns(Filter(DataSource,***filter parameters here****),"SortColumn1",Ascending,AddColumns(DataSource,""SortComboColumn2"",'SortCombo Column2'.Value),Acending)

 

Categories:
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Hi,

     

    You cannot Sort or SortByColumns on complex data fields (choice is a complex field even when its only one choice).

     

    I would recommend creating a text field on your datasource that is populated with the single choice that has been selected, then you should be able to sort/filter by these.

     

    Cheers!

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @iAm_ManCat , I am actually able to use Sort on that "complex data field" without any issues and have been using it in multiple apps for over a year.
    The documentation says it's non delegable, however it is working without delegation.

    "The following Power Apps operations, for a given data type, may be delegated to SharePoint for processing (rather than processing locally within Power Apps)."

     

    The SortByColumns on the other hand is the first time I use it and I noticed that limitation.

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Delegation means that Power Apps will attempt to delegate the action to the datasource where possible, and if it is not able to delegate then the number of records being accessed/read will not exceed the delegable limit for the App (this defaults to 500 and has a max of 2000).

     

    So in light of that, I have a few questions:

    1. Is the formula you provided copy-pasted from your App (apart from the obfuscation), as you wrote Acending instead of Ascending for the last sort type
    2. How many records are in your datasource
      1. Or more accurately, how many rows are returned by your inner filter 
        CountRows( Filter(DataSource,***filter parameters here****)​ )
    3. What exact column types are "SortColumn1" and "SortComboColumn2"
      1. Is SortColumn1 Text?
      2. Is Sort ColumnComboColumn2 Choice?

     

    Cheers,

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    In addition to this, I've done some further testing, and my investigation leads me to agree with the documentation

     

    Sort:
    image.png

    Partially working, gives delegable warning, will stop including any data after the delegable limit is reached.

    For Example, using Sort and sorting by a choice column, if only pulls the delegable limit (which in this case I have set to 2), meaning that once you have over 2k records within your inner filter, your formula will stop including all items newer than the first 2k.

    This example List has multiple items, but only two are showing as I've set the delegable limit to 2 for testing, and used a basic sort formula:

    image.png

    Additionally, whether I choose Ascending or Descending, the order is not changed, so it is not sorting...

     

    When using SortByColumns, it knows that it cannot sort by a choice field (complex data) and warns you of this:

    image.png

     

    So I stand by my original comment, the documentation says its not delegable for complex types, and I have confirmed this through testing

    image.png

  • Verified answer
    iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    There is a way to sort by a choice field by extracting the value first and then dropping the column later so that the schema of the table is kept:

     

     

     

    DropColumns(
     SortByColumns(
     AddColumns(
     Filter(DataSource,***filter parameters here****)
     ,
     "SortComboColumn2Extract", SortComboColumn2.Value
     ),
     "SortColumn1",
     Ascending,
     "SortComboColumn2Extract",
     Ascending
     ),
     "SortComboColumn2Extract"
    )

     

     

     

    This will only work within the delegable limit so your inner filter will need to always return less than the delegable limit.

     

    I have tested and confirmed this sorts correctly, however it is still reliant on the delegable limit so this needs to be kept in mind.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks, @iAm_ManCat , again, I confirm that Sort works on a choice field using the following method:

     

     

     

    Sort(Filter(MySharePointList,
     If(!IsBlank(ComboBox2.Selected.Value),ComboBox2.Selected.Value in Status.Value,true),
     If(!IsBlank(ComboBox3.Selected.Value),ComboBox3.Selected.Value in Type.Value,true)),'SortCombo Column'.Value, If(locSortAscending, Ascending, Descending)),...and so on.

     

     

     

    I indeed used a general example, not real data. sorry for the "Acending" typo. WIll try your suggestion tomorrow by extracting the choice field. My real example is much more convoluted with multiple sorting criteria and filters.
    Thank you!

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Ah ok, in your example there's no indication of the field its sorting by, only what its Filtering by - is the Sort at the end also one of your choice columns and does the sorting sort by the choice column alphabetically/numerically?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Correct, and yes. Updated the comment above with the end of that method.

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Ah yes I see what you mean, because you can reference the .Value of it which is no longer the Choice object we are filtering by but the first text value inside it instead. With SortByColumns it uses the string-based name to lookup the field and can't access sub-properties of complex items.

     

    I think the only thing we can do about this is submit an idea on the ideas forums

     

    Let me know when you've raised it and I'll vote for it!

     

    Cheers,

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

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard