cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PHarrison
Frequent Visitor

How are nested delegable functions applied to a SharePoint List?

Wonder if somebody can give me a steer here.

 

Lets say I have a SharePoint List that contains 10000 items, which are basically time records like userName,dateWorked,hoursWorked.  I want to present these in a PowerApp.

 

If a user only has 500 entries then no problem, ClearCollect(myTimeEntries, Filter(['SP table'], userName=user)) works fine.  But if a user has 2100 entries then this ClearCollect will only return 2000 entries and I'm not really sure which entries it will choose to return, is it the most recent or oldest in the List?  I only really need to show the user a couple of hundred entries, but they need to be the most recent ones.

 

So my question is when I do something like this - 

ClearCollect(myTimeEntries, Filter(Sort(['SP table'], dateWorked), userName=user))
will Sort return 2000 entries (a good portion or potentially all not being relevant to this user) to PowerApps and Filter is then applied to that 2000?  Or will Sort actually sort the 10000 items and Filter will be applied over those 10000 items, before returning the 2000 sorted and filtered items to PowerApps?


Or in other words are nested delegable calls passed through to the datasource as a single call or are they done in serial with the 2000 item limit applying to each call.

 

Trying to test myself but creating tens of thousands of entries in SP is proving messy :).

 

 

Thanks!!

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

The delegable functions are evaluated from the inside out.  So in the following:

Filter(SortByColumns('People List',"WorkState",Ascending),Title="Cunningham")

SortByColumns() is delegable so it will sort the entire data source first.  Then the Filter, which is also delegable, will run and filter out the records where the Title matches "Cunningham".  In my list of 5101 records this statement returns all the records in the environment that match the pattern, even though the last "Cunningham" record is number 5101 in the data source when sorted by state.  This will only break when you hit a function that is not delegable working from the inside out. This is a common workaround when you need to use a non-delegable filter or search.  Just make sure you have filtered the overall data source down to less than the maximum number of records before you reach the non-delegable function.



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

View solution in original post

5 REPLIES 5
Pstork1
Dual Super User III
Dual Super User III

The delegable functions are evaluated from the inside out.  So in the following:

Filter(SortByColumns('People List',"WorkState",Ascending),Title="Cunningham")

SortByColumns() is delegable so it will sort the entire data source first.  Then the Filter, which is also delegable, will run and filter out the records where the Title matches "Cunningham".  In my list of 5101 records this statement returns all the records in the environment that match the pattern, even though the last "Cunningham" record is number 5101 in the data source when sorted by state.  This will only break when you hit a function that is not delegable working from the inside out. This is a common workaround when you need to use a non-delegable filter or search.  Just make sure you have filtered the overall data source down to less than the maximum number of records before you reach the non-delegable function.



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

View solution in original post

That's great thanks!  Any chance you happen to know if you do hit the limit, is it the first or last 2000 records that are returned?  In my case I want the most recent records for a given user, so I wonder will I want to sort the date field ascending or descending?

 

Cheers!

Pstork1
Dual Super User III
Dual Super User III

If you hit the limit its the first 2,000 records that are processed based on how the list is currently formatted.



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

Guess I'm asking in what order does SharePoint process records 😀.  I can imagine it going through all records and firing them off to PowerApps as it finds them (so the first 2000 it comes across that meet the criteria), but I can also imagine it filling a buffer with discovered records and only sending the 2000 it found last, each would be fairly valid approaches.

Pstork1
Dual Super User III
Dual Super User III

For delegable functions it does all the work on the server before sending the records to Power Apps.  That's the point of delegation.  For Non-delegable functions it sends the first records in the data set to Power Apps for further processing.  The functions are processed from the innermost to the outermost.  So if the innermost uses a delegable sort operation and the next function is non-delegable then the sort will take place on the server and the first 2,000 records of the sorted data set will be sent to Power Apps.



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

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (74,977)