PowerPlatformTip 81- ‘Fast DataSource Updates’

If you don’t want to miss out on any future #PowerPlatformTip posts, be sure to subscribe to my newsletter – you’ll be the first to know whenever I publish a new tip!

💡 The Challenge:

You have a large data set in a data source (it could be SharePoint, SQL, or any other data source), and you need to update a significant portion of it. Using UpdateIf directly on the data source is not efficient and can take a long time to process.

✅ The Solution:

To tackle this challenge, you can use a combination of ClearCollect, UpdateIf on a local collection, and then Patch to update the original data source. This method is much faster and more efficient.

🔧 How It’s Done:

  1. ClearCollect: Use the ClearCollect function to create a local collection from the data source.
    PowerApps
    ClearCollect(LocalCollection, DataSource)

    Note: By default, ClearCollect has a limit of 500-2000 items based on your app settings.

  2. Update Local Collection: Use UpdateIf to update the local collection.
    PowerApps
    UpdateIf(LocalCollection, Condition, Changes)
  3. Patch Back to Data Source: Use the Patch function to update the original data source with the modified local collection.
    PowerApps
    Patch(DataSource, LocalCollection)

📌 Additional Tips:

  • Extend the Limit: If you need to work with more than the default limit of items, you can use ForAll in combination with Collect to fetch more items. (Stay tuned for a detailed Power Platform Tip on this).
  • Column Matching: Make sure the columns in your local collection exactly match those in your data source. This ensures that the Patch function works correctly.
  • Versatility of Patching: Patching collections is a versatile way to update or create both small and large sets of data in a data source. It’s crucial that the columns in the collection and the data source match exactly for this to work effectively.

🎉 Result:

You can efficiently update a large number of items in any data source without hitting performance bottlenecks.

Key Advantages:

  1. Speed: This method is faster than using UpdateIf directly on the data source.
  2. Flexibility: You can perform complex updates on the local collection before patching it back.
  3. Scalability: This approach can handle large data sets more efficiently, especially when you extend the item limit.

By using this method, you can efficiently manage large data sets in any data source, making your Power Apps more robust and responsive.

Published by

Leave a comment

Exclusive Access to #PowerPlatformTips

Don't miss your Power insights!
Subscribe now to be the first to receive notifications about new tips and tricks that will elevate your PowerPlatform skills.

Continue Reading