Post

#PowerPlatformTip 62: 'UpdateIf'

#PowerPlatformTip 62: 'UpdateIf'

TL;DR: Use UpdateIf to update every record matching a condition in one call, no manual loops needed in Power Apps.

💡 Challenge

Updating specific records in a collection often requires looping through each record, which can be inefficient and cumbersome in Power Apps.

✅ Solution

Use the UpdateIf function to target and update records that meet defined conditions, eliminating the need for manual loops.

🔧 How It’s Done

1. Define your collection

🔸 Ensure fields like Age (number) and Status (text) exist in your collection.

2. Apply the UpdateIf function

🔸 Use UpdateIf(MyCollection, Age > 30, {Status: "Senior"}) to update matching records.

3. Verify data types

🔸 Make sure the field types and value types align to avoid runtime errors.

🎉 Result

All records where Age is greater than 30 have their Status set to “Senior” in a single operation, simplifying code and boosting app performance.

🌟 Key Advantages

🔸 Flexibility: Modify only the records that match specific conditions

🔸 Efficiency: Update multiple records in a single call, improving performance

🔸 Simplicity: Clear and concise syntax for targeted updates

🛠️ FAQ

Q: What happens if no records meet the criteria?

UpdateIf leaves the collection unchanged when no records match the condition.

Q: Can I update multiple fields at once?

Yes. Pass multiple field-value pairs in the record argument, e.g. UpdateIf(MyCollection, Condition, {Status: "Senior", Active: true}).

Q: Does UpdateIf modify the original collection?

Yes. UpdateIf directly updates the existing collection in memory rather than creating a new one.

🔸 #PowerPlatformTip 57: ‘Mastering PATCH’ - the function to reach for when you need to update or insert an entire table at once, not just matching records.

🔸 #PowerPlatformTip 81: ‘Fast DataSource Updates’ - more bulk-update techniques for large data sets.

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.