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 / Delegation Warning in ...
Power Apps
Unanswered

Delegation Warning in SortByColumn

(0) ShareShare
ReportReport
Posted on by 2

When Button clicked it will update the Variable "Sorting"

UpdateContext({Sorting:"columnValue"})

 

In Gallery Item, My Code

SortByColumns(Filter(EDMS,
Publish="false",
Sorting, If(SortDescending1,Ascending , Descending)))

 

Sorting Variable Show Delegation Warning. SortByColumn of this formula might not work correctly on large data sets.

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @jf7 

    Yes, that warning it to be expected when working with ShowColumns.  The function only supports delegation partially.  The warning is telling you that ShowColumns will only return up to 2,000 records (if you have increased the limit in advanced settings).

     

    Link to MS Docs about Delegation:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview

     

    ---
    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."

  • WarrenBelz Profile Picture
    156,576 Most Valuable Professional on at

    Hi @jf7 ,

    Looks like it does not like sorting on a Variable - I got the same result.You also have a bracket int he wrong place - you may have to do this

    SortByColumns(
     Filter(
     EDMS,
     Publish="false"
     ),
     "ColumnName", 
     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.

  • jf7 Profile Picture
    2 on at

    Is there any other way to sorting based on different Column?

  • WarrenBelz Profile Picture
    156,576 Most Valuable Professional on at

    @jf7 ,

    You could so something like this

    SortByColumns(
     Filter(
     EDMS,
     Publish="false"
     ),
     If(
     Condition1,
     "Column1", 
     Condition2,
     "Column2", 
     Condition3,
     "Column3",
     ), 
     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.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @jf7 ,

    Regarding the formula that you mentioned, I think there is something wrong with it. When you use a variable name as Sort column in the SortByColumns function, the SortByColumns function would not recognize the variable as a valid column in your data source.

     

    If you want to sort your records based on different columns against a variable, I afraid that there is no direct way to achieve your needs. As an fixed solution, please check and see if the following thread solution would help in your scenario:

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Sort-sharepoint-datatable/m-p/403121

     

    Please modify your formula as below:

    If(
     Sorting = "Column1",
     SortByColumns(
     Filter(EDMS, Publish="false"),
     "Column1", // specify corresponding column name from your data source here, wrapped with double quotes
     If(SortDescending1, Ascending , Descending)
     ),
     Sorting = "Column2",
     SortByColumns(
     Filter(EDMS, Publish="false"),
     "Column2", // specify corresponding column name from your data source here, wrapped with double quotes
     If(SortDescending1, Ascending , Descending)
     ),
     Sorting = "Column3",
     SortByColumns(
     Filter(EDMS, Publish="false"),
     "Column3", // specify corresponding column name from your data source here, wrapped with double quotes
     If(SortDescending1, Ascending , Descending)
     ),
     ...
     ...
    )

    Note: Please do not add the If function inside your Filter function or SortByColumns function, otherwise, you would still cause Delegation warning issue in your formula.

     

    Regards,

  • WarrenBelz Profile Picture
    156,576 Most Valuable Professional on at

    Thanks @v-xida-msft for another angle on what I am trying to do.

    @jf7 I will wait for your response on my suggestion.

  • mdevaney Profile Picture
    29,993 Moderator on at

    @jf7 
    If you want to avoid the delegation warning use the SORT function.  It can be delegated in PowerApps.

    Use a branching SWITCH statement like this.

    Switch(
     Sorting,
    
     "Column1",
     Sort(
     Filter(EDMS, Publish="false"),
     "Column1",
     If(SortDescending1, Ascending , Descending)
     ),
    
     "Column2",
     Sort(
     Filter(EDMS, Publish="false"),
     "Column2",
     If(SortDescending1, Ascending , Descending)
     ),
    
     "Column3",
     Sort(
     Filter(EDMS, Publish="false"),
     "Column3",
     If(SortDescending1, Ascending , Descending)
     )
    )

     

     

    The response of @v-xida-msft will still raise a delegation warning because it uses SORTBYCOLUMNS.  Use SORT instead.


    ---
    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."

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard