Latest Posts

PowerApps - Update Vs UpdateIf functions


In this article, we will understand when to use Update and when to use UpdateIf function. We will understand the functionalities of Update and UpdateIf function using some simple examples.

Note:

  • Update function updates the entire record in a database
  • UpdateIf and Patch functions update only specific columns
  • Update and UpdateIf both return table as a modified data source.
  • The Update function will change all the columns of the row. So, if you don’t provide the new value for any specific column, it will update the column to a blank (“”) value in the table.

PowerApps Update function Syntax

Update( DataSource, OldRecord, NewRecord [, All ] )

  • DataSouce: This is Required. Pass the table or collection or data source on which Update operation will be fired
  • OldRecords: This is Required. The existing records to be updated.
  • NewRecords: This is Required.
    • The old records will be replaced by this record.
    • All the columns will be updated.
    • If the NewRecords-column is not having the value, then it will be updated as blank.
  • All: This is Optional.
    • There could be multiple records matching the old record. If you want to update all the records, then specify All otherwise only one record will be updated.

PowerApps UpdateIf function Syntax

UpdateIf( DataSource, Condition1, ChangeRecord1 [, Condition2, ChangeRecord2, ... ] )

  • DataSouce: This is Required. Pass the table or collection or data source on which Update operation will be fired.
  • Condition(s): This is Required. Condition to filter the data from the data source. You can use column names from the data source specified in the first argument.
  • ChangeRecord(s): the records which satisfy the above condition, can be changed using this parameter. In curly brackets, you can specify the column name and a new value of that column.

Examples

Table Name: Weathers

PowerApps Examples

PowerApps Update function examples

  • DataSource: Weathers
  • Here, you can see, I have specified only the Temperature column value to update, so the rest of the columns are blank.

Update(Weathers, First(Filter(Weathers, Humidity > 50 )), {Temperature: 99});

Output:

PowerApps Update function output

PowerApps UpdateIf function examples – one column filter one column update

  • DataSource: Weathers
  • Here, we are going to update the Temperature column value to 99 where the Humidity value is greater than 75.
  • We have updated one column value based on a single filter

    UpdateIf(Weathers, Humidity > 75 , {Temperature: 99});

Output:

PowerApps UpdateIf function output1

PowerApps UpdateIf function examples – multiple column filters multiple column update

  • DataSource: Weathers
  • Here, we are going to update the Temperature column value to 101 and the Outlook column value to “AA” where the Humidity value is greater than 75, and the Temperature value is greater than 50.
  • We have updated more than one column value using more than one filter criteria
    UpdateIf(Weathers, Humidity > 75 && Temperature > 50 , {Temperature: 101, Outlook: "AA"});

Output:

PowerApps UpdateIf function output2

Let us know if you have any difficulties using the Update or UpdateIf function, we will try to cover them here.


We value your Feedback:

Page URL:

Name:

Email:


Suggestion:

© 2024 Code SharePoint