In this article, I investigate the delegation limitations of “Sort” and “SortByColumns” functions in Power Apps, specifically focusing on dynamic sorting scenarios.
- Delegation and Data Row Limit
- Advance preparations
- Case where delegation is NOT possible with “SortByColumns”
- Case where delegation is NOT possible with “Sort”
- Conclusion
- Extras 1:It’s possible to delegate but the data limit influences the result when using “With”
- Extras 2:Combination with non-delegable functions like “AddColumns”
- Related Articles
Delegation and Data Row Limit
Delegation means “leaving the processing such as ‘Sort’ and ‘Filter’ to the data source”.
The idea is that it’s more efficient to have the data source handle the processing rather than retrieving all data into Power Apps first.
The “Data Row Limit” is the maximum number of records that Power Apps retrieves from the data source, capped at 2000.
No more than this limit will be loaded. Therefore, if you assign a large dataset to a variable or combo box, only data up to the set limit is retrieved.
However, “Galleries” and “Data tables” are exceptions: they can display more data than the limit if the query consists only of delegable functions.
Advance preparations



Case where delegation is NOT possible with “SortByColumns”
Let’s see the result with SortByColumns function which is NOT able to delegate to data source.
Put a formula in the 2nd argument
※The gallery function cannot be used due to the non-delegable formula, and the “FFFF” item which should appear at the top of the list is not displayed because it hits the Data Row Limit.




Well, it’s fine to write two or so… but when there are more conditions, it’ll be hard to read and write.

Put a formula in the 3rd argument
※Records with “Num” column value 6 won’t be displayed because the sorting is performed locally after retrieving the data.


I know it is a rare case to pass a table, but you should be careful that there is no delegation warning.
Case where delegation is NOT possible with “Sort”
Next, we’ll see the case that is NOT possible to be delegated with “Sort”
Include a formula in the second argument



When you want to delegate the processing to the data source and still want to use functions, “Sort” by itself can only specify one column, similar to “SortByColumns”.

Include object type properties in the formula
※Probably because “.” is considered an operator that accesses the property.

Conclusion
So, when you want to sort while maintaining delegation, both “Sort” and “SortByColumns” are influenced by restrictions.
When you need sorting to handle large datasets, note that it may lead to unexpected results if delegation is ignored.
※There may be other issues or cases caused by delegation.
Extras 1:It’s possible to delegate but the data limit influences the result when using “With”
Note that even if you do not use the value you assigned to a local variable in With, it will be affected by the Data Row Limit.
Extras 2:Combination with non-delegable functions like “AddColumns”




You need to consider “what kind of data you want to display” or “what kind you don’t need”.


コメント