Skip to content
Home » UpdateIf function in Power Apps

UpdateIf function in Power Apps

The UpdateIf function is used to update records in a data source that meet specific conditions. It allows you to modify single record or multiple records/bulk update at once based on the condition you define.

The condition can be any formula that returns either true or false and can reference columns from the data source by name. The function checks the condition for each record and updates any record where the result is true.




Syntax

UpdateIf(
DataSource,
Condition1, { Field1: NewValue1, Field2: NewValue2 },
Condition2, { Field1: NewValue3 }
)
  • DataSource: The table or data source you want to update.
  • Condition: A condition that determines which records should be updated.
  • Field: NewValue: Specifies which field(s) should be updated and their new values.

Here, we have a canvas app that displays basic employee details, including Name, Email, Date of Joining (DOJ), Office Location, Department, and Active Status (indicating whether the employee is still with the organization or has left) .

This canvas app uses a SharePoint list data source called ‘Employee Info’.

Update multiple records using UpdateIf function

Let’s assume you want to update the Office Location field to “Hyderabad” for employees whose Department is “CS”.

First, we add a button called “UpdateIf”. Go to the Insert tab, select the Button control, and rename it to “UpdateIf.”

Now, go to the OnSelect property of the button and write the following formula.

UpdateIf(
    'Employee Info',
    Department = "CS",
    {'Office Location': "Hyderabad"}
)

This formula uses the UpdateIf function to evaluate each record based on the given condition and updates any record that meets the criteria.

 

Now, let’s run the app and click the “UpdateIf” button to check if it updates the Office location for the matching records.




You can see that it updates the office location to “Hyderabad” for employees whose department is “CS”.

UpdateIf function with multiple condition

Lets update the records based on multiple conditon. Update the office location to “Pune” for employees in the “CS” department and to “Chennai” for those in the “Finance” department, and employee should be “Active” (means IsActive field values should be “Yes”).

Let’s modify the previous formula and write below formula.

UpdateIf(
    'Employee Info',
    Department = "CS" && isActive = "Yes",
    {'Office Location': "Pune"},
    Department = "Finance" && isActive = "Yes",
    {'Office Location': "Chennai"}
)
Now, run the app and click the “UpdateIf” button to view the results.
You can see that the values for IDs 3, 6, and 7 have been updated because they match the specified condition. ID 1 has the department “CS,” but since its Active status is “No,” it was not updated.

UpdateIf function to update single record

In case, If you want to update only single records then you can use the below formula which will update the office location to “Pune” for  Id 1.
UpdateIf( 
'Employee Info',   
ID= 1,   
{'Office Location': "Pune"}
)





Recommended for you..

Loading

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SQL BI Tutorials

Subscribe now to keep reading and get access to the full archive.

Continue reading