For anyone who has worked with Power Apps, delegation issues and warnings will not be an alien concept. Delegation is a way for Power Apps to transfer the responsibility of processing of data to the data source, rather than moving the data to the app for processing locally. Not all functions can be delegated to all data sources. If there is a function that cannot be delegated to the data source that is being used and the number of records exceeds the non-delegation record limit (which is 500 by default and can have a max value of 2000 by following these steps), then the app might not be able to retrieve all of the data, and may display wrong results. Identifying these potential issues is made easier by delegation warnings.
Imagine if there were potential delegation issues that were not flagged with delegation warnings! That would be catastrophic right? That's exactly what I ran into with one of my production apps and spent hours figuring why I was only seeing 500 records when I had taken care of all the delegation warnings in my app.
Per Microsoft Docs "Table shaping functions like AddColumns, DropColumns, RenameColumns, and ShowColumns partially support delegation. Formulas in their arguments can be delegated. However, the output of these functions are subject to the non-delegation record limit." What this means is that even if there is an expression that can be delegated to the data source, if it is included within AddColumns, the output of AddColumns will be subject to the non-delegation record limit. What makes this worse is that this will not be flagged as a delegation warning.
I am going to illustrate this with an example. The app used in this example has it's non-delegation record limit set to 5.
The first gallery is a list of Users that allows searching by full name. There are no delegation warnings with this function as it can be delegated to the data source (CDS in this case). The number of records returned is 100 (not affected by the non-delegation record limit).
The Items property of the gallery is set to:
Search(Users, TextSearchBox17_1.Text, "fullname")
Consider a similar gallery of Users that allows searching by the name of the user who created the records (Created By). To allow this, AddColumns can be used to add a new column to store the full name of the Created By user for each record. Now, irrespective of the fact that the expression within the AddColumns function is one that can be delegated, the number of records returned by the AddColumns function is 5 (the non-delegation record limit).
The Items property of the gallery is set to:
Search(AddColumns(Users, "CreatedByName", 'Created By'.'Full Name'), TextSearchBox17_1.Text, "CreatedByName")
As you can notice, there is no delegation warning with this formula although it is only partially delegable and the number of records returned is in fact limited by the non-delegation record limit. This can make identifying the root cause of why all records aren't returned very difficult.
The purpose of this post was to increase awareness of the fact that partially delegable functions do not come with delegation warnings. Hopefully, no one will ever have to spend hours to figure out why only a small number of records are returned even without any delegation warnings.
Have fun! Get addicted!
1 thought on “The invisible delegation issue”