cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HansHeintz
Post Patron
Post Patron

SQL First;sortbycolumns suddenly delegation error

Hi,

 
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))})

 

12 REPLIES 12

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

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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