From fcd577ba872767ceb730add1b00b9e4007615fdf Mon Sep 17 00:00:00 2001
From: BCBuizer <112906720+BCBuizer@users.noreply.github.com>
Date: Mon, 27 May 2024 14:12:41 +0200
Subject: [PATCH] Clarification added and functions updated
Added a clarification for how the UpdateIf function behaves in case multiple conditions/changerecords are applied.
Also updated two occasions of First(Filter()) with LookUp().
---
.../power-fx/reference/function-update-updateif.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/power-platform/power-fx/reference/function-update-updateif.md b/power-platform/power-fx/reference/function-update-updateif.md
index dba16e1101..a61a04c7fd 100644
--- a/power-platform/power-fx/reference/function-update-updateif.md
+++ b/power-platform/power-fx/reference/function-update-updateif.md
@@ -62,7 +62,7 @@ Delegation support for UpdateIf and RemoveIf is now in Experimental Preview (def
**UpdateIf**( _DataSource_, _Condition1_, _ChangeRecord1_ [, *Condition2*, *ChangeRecord2*, ... ] )
- _DataSource_ – Required. The data source that contains the record or records that you want to modify.
-- _Condition(s)_ – Required. A formula that evaluates to **true** for the record or records that you want to modify. You can use column names of _DataSource_ in the formula.
+- _Condition(s)_ – Required. A formula that evaluates to **true** for the record or records that you want to modify. You can use column names of _DataSource_ in the formula. In case multiple _Conditions_ are passed, only the _ChangeRecord_ related to the first _Condition_ that evaluates to **true** is applied.
- _ChangeRecord(s)_ - Required. For each corresponding condition, a change record of new property values to apply to records of _DataSource_ that satisfy the condition. If you provide the record inline using curly braces, property values of the existing record can be used in the property formulas.
## Examples
@@ -73,9 +73,9 @@ In these examples, you'll replace or modify records in a data source that's name
| Formula | Description | Result |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| **Update( IceCream,
First( Filter( IceCream, Flavor="Chocolate" ) ), { ID: 1, Flavor: "Mint Chocolate", Quantity:150 } )** | Replaces a record from the data source. | ![Replace a record.](media/function-update-updateif/icecream-mint.png)
The **IceCream** data source has been modified. |
+| **Update( IceCream,
LookUp( IceCream, Flavor="Chocolate" ), { ID: 1, Flavor: "Mint Chocolate", Quantity:150 } )** | Replaces a record from the data source. | ![Replace a record.](media/function-update-updateif/icecream-mint.png)
The **IceCream** data source has been modified. |
| **UpdateIf( IceCream, Quantity > 175, { Quantity: Quantity + 10 } )** | Modifies records that have a **Quantity** that is greater than **175**. The **Quantity** field is incremented by 10, and no other fields are modified. | ![Modify records.](media/function-update-updateif/icecream-mint-plus10.png)
The **IceCream** data source has been modified. |
-| **Update( IceCream,
First( Filter( IceCream, Flavor="Strawberry" ) ),
{ ID: 3, Flavor: "Strawberry Swirl"} )** | Replaces a record from the data source. The **Quantity** property hasn't been supplied in the replacement record, so that property will be _blank_ in the result. | ![Replace record when quantity not supplied.](media/function-update-updateif/icecream-mint-swirl.png)
The **IceCream** data source has been modified. |
+| **Update( IceCream,
LookUp( IceCream, Flavor="Strawberry" ),
{ ID: 3, Flavor: "Strawberry Swirl"} )** | Replaces a record from the data source. The **Quantity** property hasn't been supplied in the replacement record, so that property will be _blank_ in the result. | ![Replace record when quantity not supplied.](media/function-update-updateif/icecream-mint-swirl.png)
The **IceCream** data source has been modified. |
| **UpdateIf( IceCream, true, { Quantity: 0 } )** | Sets the value of the **Quantity** property for all records in the data source to 0. | ![Set quantity for all to 0.](./media/function-update-updateif/icecream-mint-zero.png)
The **IceCream** data source has been modified. |
### Step by step