What Is a Collection?
A collection is a temporary, in-memory table stored locally while the app is running.
It disappears when the app closes unless explicitly saved using SaveData().
Collections are ideal for:
- Storing user selections
- Caching data from connectors
- Building editable tables
- Passing data into components
- Shaping data for galleries
Now let’s explore the commands that make collections so powerful.
1. Creating and Adding Data
Collect()
Adds one or more records to a collection.
If the collection doesn’t exist, Power Apps creates it automatically.
When to use it
- Append rows
- Add items to a cart
- Build a running list
Example
Collect( Cart, { ProductID: 101, Name: "Laptop", Price: 999 } )
What happens
- If
Cart doesn’t exist → it’s created
- The record is added as a new row
ClearCollect()
Clears the collection, then adds new data.
When to use it
- Loading data from a data source
- Resetting a collection
- Refreshing a filtered dataset
Example
ClearCollect( ActiveUsers, Filter(Users, Status = "Active") )
What happens
ActiveUsers is emptied
- The filtered records are inserted
2. Removing Data
Remove()
Removes specific records that match exactly.
When to use it
- Removing a selected row from a gallery
- Deleting a specific item
Example
Remove(Employees, ThisItem)
Important
The record must match exactly — including all fields.
RemoveIf()
Removes all records that match a condition.
When to use it
- Bulk deletes
- Clearing items by status
- Removing expired or invalid data
Example
RemoveIf(Tasks, Completed = true)
3. Updating Data
Patch()
Updates an existing record or inserts a new one.
When to use it
- Editing a row in a gallery
- Updating only specific fields
- Upserting (update or insert)
Example
Patch( Inventory, LookUp(Inventory, ID = 5), { Quantity: Quantity + 1 } )
Why Patch is powerful
- Partial updates
- Doesn’t overwrite the whole record
- Works with data sources and collections
Update()
Replaces an entire record with a new one.
When to use it
- You want to overwrite the whole row
- You’re replacing a record with a new version
Example
Update( Employees, ThisItem, { Name: "Steve", Role: "Consultant", Active: true } )
UpdateIf()
Updates all records that match a condition.
When to use it
- Bulk updates
- Changing statuses
- Applying a rule to multiple rows
Example
UpdateIf( Orders, Status = "Pending", { Status: "Processing" } )
4. Clearing Data
Clear()
Deletes all records from a collection.
When to use it
- Resetting a collection
- Clearing a cart
- Starting fresh
Example
5. Reading and Inspecting Data
These functions don’t modify collections, but they’re essential when working with them.
LookUp()
Returns a single record that matches a condition.
Example
LookUp(Employees, ID = 10)
Filter()
Returns a table of matching records.
Example
Filter(Products, Price < 50)
First(), Last(), FirstN(), LastN()
Access specific rows.
Example
6. Table-Shaping Functions (Often Used With Collections)
These don’t change the collection itself — they return a new table.
AddColumns()
Adds calculated columns.
AddColumns(Employees, "IsAdult", Age >= 18)
DropColumns()
Removes columns.
DropColumns(Employees, "InternalNotes")
RenameColumns()
Renames columns.
RenameColumns(Employees, "Name", "FullName")
ShowColumns()
Keeps only the columns you specify.
ShowColumns(Employees, "Name", "Email")
GroupBy() / Ungroup()
Creates nested tables or flattens them.
GroupBy(Orders, "CustomerID", "CustomerOrders")
7. Saving and Loading Collections (Offline Scenarios)
SaveData()
Saves a collection to local storage.
SaveData(Cart, "CartData")
LoadData()
Loads a previously saved collection.
LoadData(Cart, "CartData", true)
Quick Reference Table
|
|
|
|
Collect() |
|
|
ClearCollect() |
|
|
Remove() |
|
|
RemoveIf() |
|
|
Patch() |
|
|
Update() |
|
|
UpdateIf() |
|
|
Clear() |
|
|
LookUp() |
|
|
Filter() |
|
|
AddColumns() |
|
Final Thoughts
Collections are deceptively simple but incredibly powerful. Once you understand how each command works — especially the differences between Collect, Patch, Update, and ClearCollect — you can build dynamic, responsive apps that feel polished and professional.