cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DAVIDPOWELL
Post Prodigy
Post Prodigy

Delegation on getting MAX with FILTER on error for SQL SERVER

I have a piece of PATCH code but needing a  MAX with it.  getting a  delegation error for sql server

Max(Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry]',ID_Racfid = lbl_Racfid.Text), Value(NSC_Id))


// This make an entry in the trans/time table. a write back to time entry table
Patch(
'[dbo].[t_nsc_trackcode_trans_time_entry]',
Defaults('[dbo].[t_nsc_trackcode_trans_time_entry]'),
{
NSC_ID_Ref:Max(Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry]',ID_Racfid = lbl_Racfid.Text), Value(NSC_Id)),

opened_at: varDate, 
inprogress_or_closed_at: varDate 
}
);

 

thanks 

dave

1 ACCEPTED SOLUTION

Accepted Solutions
gabibalaban
Super User II
Super User II

Hi @DAVIDPOWELL ,

Based on @Pstork1 observation, the simpliest way to achieve your goal is to use a collection as filter result and then to use Max() on this collection.

Like this:

ClearCollect(filteredData,Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry]',ID_Racfid = lbl_Racfid.Text));
Patch(
'[dbo].[t_nsc_trackcode_trans_time_entry]',
Defaults('[dbo].[t_nsc_trackcode_trans_time_entry]'),
{
NSC_ID_Ref:Max(filteredData, Value(NSC_Id)),
opened_at: varDate, 
inprogress_or_closed_at: varDate 
}
);

This way should get rid of your delegation warning.

 

Hope it helps !

View solution in original post

2 REPLIES 2
Pstork1
Dual Super User III
Dual Super User III

MAX() is only delegable in SQL server for a number column.  Since you have NSC_Id inside a Value() its not a number column and Max can't be delegated. If the Filter will get you below the data row limit you can ignore the warning.  It is a warning, not an error.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
gabibalaban
Super User II
Super User II

Hi @DAVIDPOWELL ,

Based on @Pstork1 observation, the simpliest way to achieve your goal is to use a collection as filter result and then to use Max() on this collection.

Like this:

ClearCollect(filteredData,Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry]',ID_Racfid = lbl_Racfid.Text));
Patch(
'[dbo].[t_nsc_trackcode_trans_time_entry]',
Defaults('[dbo].[t_nsc_trackcode_trans_time_entry]'),
{
NSC_ID_Ref:Max(filteredData, Value(NSC_Id)),
opened_at: varDate, 
inprogress_or_closed_at: varDate 
}
);

This way should get rid of your delegation warning.

 

Hope it helps !

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

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

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,464)