Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

Add/Update Collection in Power Apps [With Various Examples]

The Power Apps collection is a temporary storage area for data. Sometimes, we need to update or add a new record to the collection. Follow this tutorial to learn more about the Power Apps update collection. Such as:

  • Update Collection in Power Apps
  • How to Add Items to Collection in Power Apps

Update Collection PowerApps

Updating a Power Apps collection typically involves adding, modifying, or removing records from the collection based on user actions or other events within the application.

Suppose you want to update the collection item in Power Apps; you can use two different functions. Such as:

  1. Update: The Power Apps Update Function is used to replace the entire record in a data source
  2. UpdateIf: The Power Apps UpdateIf Function is used to modify one single or more values in one or more records that match one or more conditions

1. PowerApps Update Function Syntax:

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

Where,

  • DataSource = This contains all the records that you want to replace. It may be a Table, Collections, etc
  • OldRecord = It is the record that you want to replace
  • NewRecord = It is the replacement record. This is not a change record. Here, the entire record is replaced
  • All = Mention the All argument to remove all copies of the record

2. PowerApps UpdateIf Function Syntax:

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

Where,

  • DataSource = This data source contains one or more records you want to modify
  • Condition(s) = In this condition, you can use column names of DataSource in the formula. It evaluates to True for the record that you want to modify
  • ChangeRecord(s) = You can provide a change record of new property values that satisfy the condition

Power Apps Update Collection [Using Update Function]

I have created a Power Apps collection named “colProducts” from my SharePoint list [Product Details]. This list contains the below fields.

Column NameData Type
Product NameIt is a default single line of text
ManufacturerChoice
PriceCurrency
QuantityNumber
Purchase DateDate and time
power apps update collection

In Power Apps, there is a Gallery control retrieving all the collection records, as shown below

power apps add to collection

Now, I would like to update the Title, Price, and Quantity based on the Title field [Product Name]. The output is shown in the screenshot below.

how to update a collection in powerapps

To do so, follow the below steps. Such as:

1. To Create a Power Apps collection using a SharePoint list, select the App object and set its OnStart property to the code below.

OnStart = ClearCollect(colProducts, 'Product Details')

Where,

  • colProducts = Power Apps collection
  • ‘Product Details’ = SharePoint Online list
update collection in powerapps

2. On the Power Apps Screen -> Insert a Gallery control and set its Items property to the code below.

Items = colProducts
how to update collection in powerapps

3. Finally, insert a Button control [Update Collection] and set its OnSelect property as:

OnSelect = Update(
    colProducts,
    First(
        Filter(
            colProducts,
            Title = "Laptop"
        )
    ),
    {
        Title: "Apple MacBook Pro 14",
        Price: 1500,
        Quantity: 4
    }
)

Where,

  • Title, Price, Quantity = Power Apps collection fields