In Microsoft Power Apps, updating records in a data source or collection is a common task.
Two functions often used for this purpose are Update and UpdateIf.
Although both functions modify data, they behave very differently. Understanding this difference is essential to avoid unintended data loss and to update records efficiently.
This article explains how the UpdateIf function works, how it compares with the Update function, and how you can use it to update multiple records or even a data source directly.
Sample Data: Employees Collection
Imagine an app that creates a collection called Employees in the OnStart property. The collection contains three employee records with the following fields:
- ID
- Name
- Department
- Location
- Hire Date
A gallery displays the records by setting its Items property to the Employees collection. The app also contains two buttons:
- Update – demonstrates the behavior of the
Updatefunction - UpdateIf – demonstrates how
UpdateIfworks
Using the Update Function
The Update function modifies an entire record. To update a specific employee, the formula first needs to locate the record using LookUp.
Update(
Employees,
LookUp(Employees, ID = 2),
{
Name: "Mary Johnson"
}
)
This formula searches for the employee whose ID equals 2 and changes the name to Mary Johnson.
Important Behavior of Update
After running this formula, you may notice something unexpected:
- The name is updated correctly.
- Other fields such as department, location, and hire date become blank.
This happens because the Update function replaces the entire record. If you specify only one field, the rest will be cleared unless you explicitly include them in the update.
Therefore, when using Update, you must provide values for every field in the record.
Using the UpdateIf Function
The UpdateIf function behaves differently. Instead of replacing the entire record, it updates only the fields you specify.
UpdateIf(
Employees,
ID = 3,
{
Name: "Arnold",
Location: "Houston"
}
)
What Happens Here?
- The employee with
ID = 3is found. - The Name and Location fields are updated.
- The other fields remain unchanged.
Unlike Update, you do not need a LookUp function. The condition (ID = 3) directly identifies the record to modify.
Key Difference Between Update and UpdateIf
| Function | Behavior |
|---|---|
| Update | Replaces the entire record. All fields must be provided. |
| UpdateIf | Updates only the specified fields. |
Bulk Updates with UpdateIf
One powerful capability of UpdateIf is the ability to update multiple records at once. For example:
UpdateIf(
Employees,
ID > 1,
{
Department: "HR"
}
)
This formula updates every employee whose ID is greater than 1. In this case, both employee records with ID 2 and 3 will have their department changed to HR.
Bulk updates like this cannot be done with the Update function.
Updating a Data Source (Dataverse Example)
The UpdateIf function can also update records directly in a data source such as Dataverse. Suppose a gallery is connected to a Products table with the following fields:
- Name
- Price
- Status
To change the price of a product named Smartphone, you could use:
UpdateIf(
Products,
Name = "Smartphone",
{
Price: 700
}
)
If the current price is 500, running this formula updates it to 700 directly in the Dataverse table.
Delegation Warning
An important limitation of UpdateIf is that it is not delegable.
Delegation determines whether Power Apps can process queries directly in the data source. Because UpdateIf is not delegable, it only processes a limited number of records locally.
By default, Power Apps processes only the first 500 records.
For example:
- If your database contains 10,000 records
- And your formula targets all records where
ID > 1 - Only the first 500 records may be updated
This limitation is important to consider when working with large datasets.
Alternative: The Patch Function
Another commonly used method for updating records in Power Apps is the Patch function.
Many developers prefer it because it offers more flexibility and better control when modifying records.
Conclusion
The UpdateIf function is a powerful tool for modifying records in Power Apps. It allows you to:
- Update specific fields without replacing the entire record
- Update multiple records at once
- Modify records directly in a data source like Dataverse
However, remember that UpdateIf is not delegable, which can affect apps that work with large datasets.
For more advanced scenarios, consider using the Patch function.

Leave a Comment