In this webinar, our experts showcase a variety of demo use cases of how different components of the...
Delegation is a very important concept to understand, especially if you are working with large sets of data in PowerApps. For example, when performing operations, like filtering or searching for specific records in PowerApps, delegation offloads the work to the data source. What that really means is that operations like Search, Filter, and Lookup are performed at the data source instead of bringing the whole set of data to the device and then processing it locally. In essence, delegation is much more powerful method, as it processes data faster and improves performance of the app. Delegable sources are Dynamics 365 (CRM), Common Data Service for Apps, SharePoint, and SQL Server. In today’s blogpost, we’ll discuss common delegation warnings and how to avoid them.
Note that, generally speaking, delegation does not apply to data sets with less than 500 records, as those can be processed on the device without issue. While this “limit” can be changed, doing so may sacrifice performance.
If you get a delegation warning while performing operations in your formulas, it means that one or more of the operations being performed cannot be offloaded to the other server for one of several reasons:
Example #1 – The following filter throws a delegation warning:
Filter(Jobs, 'Tentative Job Start Date' <= DateAdd(Today(),7, Days) )
Issue: DateAdd is not a constant value. The filter depends on the value of this expression, but the expression is not delegable to the data source (not in the list of supported operations). As a result, the entire filter operation cannot be delegated.
Solution: Evaluate the DateAdd expression separately and store the value in a variable (DateLimit) to be used in the Filter function. DateLimit is a constant value at the time of filtering. The filter no longer throws a delegation warning.
Set(DateLimit, DateAdd(Today(),7, Days));
Filter(Jobs, 'Tentative Job Start Date' <= DateLimit )
Example #2 – The following filter throws a delegation warning:
Filter(Jobs, 'Project Manager' = LookUp(Users, domainname = User().Email, systemuserid))
Issue: LookUp is not a constant value The filter depends on the value of this expression, but the expression is not delegable to the data source (not in the list of supported operations). As a result, the entire filter operation cannot be delegated.
Solution: Evaluate the LookUp expression separately and store the value in a variable (UserGuid) to be used in the Filter function. UserGuid is a constant value at the time of filtering. The filter no longer throws a delegation warning.
Set(UserGuid, LookUp( Users, domainname = User().Email , systemuserid) );
Filter(Jobs, 'Project Manager' = UserGuid )
As you can see from the examples above, using only constant values in your filter expressions, separating other independent calculations, and storing the result in a variable will eliminate delegation warnings. It is also helpful to use only expressions that are supported, as described in the linked article above.
Happy PowerApps’ing!