Delegation, powerful concept when working with PowerApps helps in improving app performance by limiting amount of data movement over network. To be precise, delegation will delegate (move) as much data processing down to data layer as is possible instead of retrieving all data and process locally for better performance. Here by processing data means: sorting, filtering, transforming.

D1

Refer article which explains Delegation beautifully and in very much detail.

PowerApps achieve delegation through delegable data sources and functions. You can refer list of delegable sources and functions here. When working with large data sets, it is recommended to use delegable data sources and functions to keep your app performing well.

What happens when Non-delegable function is used?

Functions such as Sort, Filter, Lookup, Aggregate functions are delegable and can be used with large data sets with no issues. But functions such as AddColumns, DropColumns, Concat, Clear, ClearCollect, GroupBy are Non-Delegable functions (Refer here for complete list). Since these functions cannot be delegated, use of these functions will retrieve large sets of data over network and process them locally which will slow down app.

To avoid this, PowerApps imposes a limit on the amount of data that can be processed locally: 500 records by default. In that case if your data source has more than 500 records, only first 500 will be retrieved.

Demo – Use of Delegable vs Non-Delegable function

  • I have list of 600 Products in Azure SQL DB which are displayed in Gallery control using SQL Server connection. These products are categorized as 1-150 Amazon products, 151-300 HCL Products, 301-500 Microsoft Products, 501-600 PowerObjects products.

D2

  • Select Items property of Gallery control and update with below formula to enable search and filters record in list when user types in search text box

Search(‘[dbo].[CompanyProducts]’, TextSearchBox2.Text,”ProductName”)

D3

  • When you search “Power”, list will be filtered for PowerObjects products only. Since Search is a delegable function, search function processing will be done at data layer (SQL table level) and when user search for “Power”, only PowerObjects products will be returned from data source.

D4

  • Let’s add non-delegable function to above formula “AddColumns” to add ProductUniqueID column. Select Items property of Gallery control again and update with below formula

Search(AddColumns(‘[dbo].[CompanyProducts]’, “ProductUniqueID”, ProductName & “_” & ID), TextSearchBox2.Text,”ProductName”)

  • Now when you search for “Power”, list will be empty. Reason is due to AddColumns non-delegable function, PowerApp retrieved only first 500 records from data source and PowerObejcts products do not fall in this range.

D5

You can mitigate this problem by using Collections in PowerApps. Collections helps to store data locally as temporary storage and you can store as many records as you want. For more information on Collections please refer my blog.

Increase 500 records limit

There is a reason why PowerApps chose this number because increase in this limit will degrade app performance. But you can always update this limit (1000-2000) based on your needs.

  • Go to File menu, Select Experimental Features in App Settings. Change value for Data row limit for non-delegable queries.

D6

  • Once limit is updated to 600, PowerObjects products will be shown when user types “power” in search text box

D7

References:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview