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

Welcome to the User Group Public Preview

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

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (34,767)