While working in PowerApps with collections, performance should be managed right from keeping the sizes of these collections optimized; for large collections can delay the execution of the applications.
Since collections are kept in memory, avoid holding important data in them that would want persistence; external data sources are best suited for that.Another important point is to make your queries on the collections delegation-friendly, especially in large data sets. Also, always clear or initialize any collections to prevent leftover data issues. Finally, collections are reset each time the application is closed, so data management must be adjusted to accommodate this accordingly.
ClearCollect
ClearCollect(colStudents, {Name: “Akira”, Age: 18}, {Name: “Alice”, Age: 22});
Copied!
Collect
Collect(colStudents, {Name: “Nirav”, Age: 20});
Copied!
Clear
Clear(colStudents);
Copied!
Remove
Remove(colStudents, LookUp(colStudents, Name = “Akira”));
Copied!
RemoveIf
RemoveIf(colStudents, Age < 20);
Copied!
Update
Update(colStudents, LookUp(colStudents, Name = “Akira”), {Age: 21});
Copied!
UpdateIf
UpdateIf(colStudents, Age = 18, {Age: 19});
Copied!
AddColumns
ClearCollect(colUpdatedStudents, AddColumns(colStudents, “Status”, If(Age >= 21, “Adult”, “Minor”)));
Copied!
DropColumns
ClearCollect(colUpdatedStudents, DropColumns(colStudents, “Age”));
Copied!
ShowColumns
ClearCollect(colFilteredStudents, ShowColumns(colStudents, “Name”));
Copied!
LookUp
LookUp(colStudents, Name = “Murakami”);
Copied!
FirstN
ClearCollect(colFirstTwo, FirstN(colStudents, 2));
Copied!
LastN
ClearCollect(colLastTwo, LastN(colStudents, 2));
Copied!
Note by Akira28
- Performance: Minimize collection size to prevent slowdowns.
- Memory: Large collections may exhaust device memory.
- Data Persistence: Collections reset when the app closes, so store critical data externally.
- Delegation: Ensure collection operations are delegation-friendly for larger datasets.
- Initialization: Always clear or initialize collections to prevent residual data issues.