Showing results for 
Search instead for 
Did you mean: 
Helper V
Helper V

SQL First;sortbycolumns suddenly delegation error


This code, using sql server suddenly comes back with a delegation error where it worked perfectly for months:
When I played as a kid it was considered unfair to change the rules while playing and I guess my users still feel the same way.


;;UpdateContext({FoundDier:First(SortByColumns(Filter('[dbo].[dier]';LastInputString in naam);"dier_id";Descending))})



Ignoring the warning might be fine but at the end of the day I don't want warnings to remain otherwise at some point I can no longer see the forest for the trees.

Hi @HansHeintz ,

According to your scenario, I think the Delegation limit would not affect your needs. The following formula could achieve your needs:

Set(MaxRecID; First(FirstN(Sort('[dbo].[dier]'; dier_id; Descending); 1)).dier_id)


In above formula, the Sort formula is delegable, so it could sort your SQL Table ('[dbo].[dier]') records based on the "dier_id" column properly in Descending order. The Sort formula could delegate the data process to your SQL Table properly without any Delegation issue. The max dier_id value would be at the first record in your Sort formula result.


The FirstN functionality is not a Delegable function, so it could only process first 2000 records locally at most. So the FirstN function could only process first 2000 records at most from the Sort formula result. The max dier_id value has been existed at the first record of the first 2000 records from the Sort formula result.

Note: Please make sure you have set the "Data row limit for Non-delegable queries" option to maximum value -- 2000 within Advanced settings of App settings of your app.


Best regards,

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

Thanks, already posted this solution myself above so will mark that as the solition 😜

Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,457)