Hello Community!
I've been working with Power Platform for over a year now and have been able to climb a steep learning curve. Unfortunately, there is one thing I still can't get my head around and that is the concept of delegation.
So far I've been able to muddle through without it holding me back, partly because - against the advice of experts and Microsoft itself - I've "cheated" in some cases. For example, I always loaded all data records (rows) from my data source into the app in advance and then filtered them according to the desired result. When starting the Canvas applications, sometimes more than 5000 entries are loaded directly. (This is done by loading the datasource several times into a collection). It was therefore foreseeable that at some point we would reach the point where the loading times would exceed the limits of what is tolerable.
To ensure that this does not happen in the future and that I stick to the official documentation, I would like to better understand the concept of delegation and would like to ask you to answer a few questions.
Let's stay with the example of 5000 rows in a sharepoint list.
So without the manipulations on my part, a maximum of 2000 rows would be loaded.
This describes which filter queries / actions can be delegated and which cannot.
In our example, we would have to work with the "in"-Function because the alternative "StartsWith" function is not relevant because the desired item must be found even if a word is typed in the middle of the respective column.
However, the "in"-Function cannot be delegated. Does this mean that when an item is searched for using "in", it is only searched for in the 2000 records that have been loaded into the app?
So my sharepoint list has 5000 records. A maximum of the first 2000 are loaded into the app. If I now use the search function to search for "Red" (using the "in" function), this is only applied to the items that have been loaded into the app..
OR
will the search "only" load 2000 rows from the sharepoint list for which the search was successful?
If the second option is true, then it would be enough for us to stop manipulating Power Apps with the collection trick.
Here is a simplified version of the code I use for the "Items" property of my Gallery:
SortByColumns(
Filter(
Collection;
IsBlank(
Find(
"0";
Concat(
Filter(
ForAll(
Split(
Concatenate(
TextSearchBox1;
" ";
Dropdown1.Selected.Value;
" ";
Dropdown2.Selected.Value
);
" "
);
{Result: ThisRecord.Value}
);
!IsBlank(Result)
);
If(
TrimEnds(Result) in 'Column1' || TrimEnds(Result) in 'Column2';
"1";
"0"
)
)
)
)
);
"DateTime"
)
Concatenate(TextSearchBox1; " "; Dropdown1.Selected.Value; " "; Dropdown2.Selected.Value): This function concatenates the values from TextSearchBox1, Dropdown1, and Dropdown2 with spaces in between.
Split(Concatenate(...); " "): This function splits the concatenated values into individual elements based on the space delimiter.
ForAll(Split(...); {Result: ThisRecord.Value}): This function iterates through each element in the split collection and creates a new collection where each element is an object that has a Result attribute containing the value of the current element.
Filter(ForAll(...); !IsBlank(Result)): This function filters the collection to retain only those elements whose Result attribute is not blank.
Concat(Filter(...); If(TrimEnds(Result) in 'Column1' || TrimEnds(Result) in 'Column2'; "1"; "0")): This function iterates through each element in the filtered collection and returns either “1” or “0” depending on whether the Result attribute is present in ‘Column1’ or ‘Column2’. The return values are then concatenated into a single string.
Find("0"; Concat(...)): This function searches for the first occurrence of “0” in the concatenated string.
IsBlank(Find(...)): This function checks whether the result of the Find function is blank.
Filter(Collection; IsBlank(Find(...))): This function filters the original collection Collection to retain only those elements for which the IsBlank(Find(...)) function returns true.
SortByColumns(Filter(...); "DateTime"): Finally, this function sorts the filtered collection by the “DateTime” column.
In summary, the code within the Items-Property filters and sorts the collection based on values from the text search box and two dropdown menus.
We will never need 2000 items AFTER searching.
Could Dataverse be a better data source for our case (in terms of the search algorithm we use for filtering the gallery items)?
I am ready to be taught better. Thanks in advance for your help! 😊

Report
All responses (
Answers (