Using Concurrent Function for Parallel Processing

Loading

Using the Concurrent Function for Parallel Processing in Power Apps

Introduction

When working with multiple data sources, large datasets, or API calls, loading them sequentially can significantly slow down app performance. The Concurrent() function in Power Apps allows you to run multiple operations in parallel, reducing the time taken to fetch and process data.

This guide provides a detailed, step-by-step explanation of how to use Concurrent() effectively in Power Apps to optimize performance and improve the user experience.


1. What is the Concurrent() Function?

1.1 Definition

The Concurrent() function allows multiple formulas or expressions to execute simultaneously, instead of running one after another (sequentially).

1.2 Why Use Concurrent()?

Faster Data Loading → Fetch multiple data sources at the same time instead of waiting for each one to complete.
Optimized App Performance → Reduces screen load times and improves responsiveness.
Better User Experience → Users don’t have to wait for unnecessary delays.
Reduces API Call Delays → If your app makes API calls, Concurrent() helps execute them simultaneously.


2. Understanding Sequential vs Parallel Processing

2.1 How Sequential Processing Works (Without Concurrent())

When loading multiple data sources sequentially, Power Apps waits for each operation to complete before starting the next.

ClearCollect(CustomersData, Customers);
ClearCollect(OrdersData, Orders);
ClearCollect(ProductsData, Products);

🚨 Problem: Each ClearCollect() runs one after another, increasing load time.

2.2 How Parallel Processing Works (With Concurrent())

Using Concurrent(), all data collections load simultaneously, reducing total load time.

Concurrent(
    ClearCollect(CustomersData, Customers),
    ClearCollect(OrdersData, Orders),
    ClearCollect(ProductsData, Products)
)

Now, Power Apps fetches all three data sources in parallel, cutting down load time.


3. How to Use the Concurrent() Function

3.1 Using Concurrent() to Load Multiple Data Sources Faster

Instead of loading multiple collections one by one, group them inside a Concurrent() function.

Before (Slow Sequential Data Loading)

ClearCollect(Employees, EmployeesTable);
ClearCollect(Departments, DepartmentsTable);
ClearCollect(Salaries, SalariesTable);

🚨 Problem: Each dataset loads only after the previous one finishes, making the app slower.

After (Optimized Parallel Data Loading with Concurrent())

Concurrent(
    ClearCollect(Employees, EmployeesTable),
    ClearCollect(Departments, DepartmentsTable),
    ClearCollect(Salaries, SalariesTable)
)

All three collections load at the same time, reducing overall wait time.


3.2 Using Concurrent() in OnStart for Faster App Initialization

If your app loads data on startup, placing multiple ClearCollect() statements inside App.OnStart can slow down app launch.

Before (Slow OnStart Processing Without Concurrent())

ClearCollect(UserData, Users);
ClearCollect(CustomerData, Customers);
ClearCollect(ProductData, Products);

🚨 Problem: The app loads each collection sequentially, increasing startup time.

After (Optimized OnStart with Concurrent())

App.OnStart = Concurrent(
    ClearCollect(UserData, Users),
    ClearCollect(CustomerData, Customers),
    ClearCollect(ProductData, Products)
)

The app launches faster because all data loads at the same time.


3.3 Using Concurrent() for Multiple API Calls

If your app fetches data from APIs, using Concurrent() reduces the time spent waiting for responses.

Before (Slow API Calls Processed Sequentially)

Set(Response1, Office365Users.SearchUser({searchTerm: "John"}));
Set(Response2, Office365Users.SearchUser({searchTerm: "Michael"}));
Set(Response3, Office365Users.SearchUser({searchTerm: "Sarah"}));

🚨 Problem: Each API call waits for the previous one to finish.

After (Optimized API Calls with Concurrent())

Concurrent(
    Set(Response1, Office365Users.SearchUser({searchTerm: "John"})),
    Set(Response2, Office365Users.SearchUser({searchTerm: "Michael"})),
    Set(Response3, Office365Users.SearchUser({searchTerm: "Sarah"}))
)

Now, all API calls happen at the same time, reducing the total API response time.


3.4 Using Concurrent() to Improve Performance in Galleries

If a gallery depends on multiple datasets, Concurrent() helps load all data faster.

Before (Inefficient Gallery Data Loading)

ClearCollect(OrdersData, Orders);
ClearCollect(CustomersData, Customers);
ClearCollect(ProductsData, Products);

🚨 Problem: Users must wait for each dataset to load before the gallery updates.

After (Faster Gallery Data Loading with Concurrent())

Concurrent(
    ClearCollect(OrdersData, Orders),
    ClearCollect(CustomersData, Customers),
    ClearCollect(ProductsData, Products)
)

Gallery updates faster since all data loads in parallel.


4. Best Practices for Using Concurrent()

Use Concurrent() in App.OnStart to speed up app launch.
Use Concurrent() when loading multiple collections to minimize load time.
Use Concurrent() when making multiple API calls to reduce wait time.
Avoid placing Patch(), Update(), or SubmitForm() inside Concurrent() (These require sequential execution).
Test performance improvements → Compare load time before and after using Concurrent().


5. When NOT to Use Concurrent()

⚠️ When Actions Depend on Each Other → If one action requires the result of a previous one, don’t use Concurrent().
⚠️ When Modifying the Same Data Source → If multiple operations update the same collection, running them in parallel can cause conflicts.
⚠️ With Patch(), Update(), or Remove() → These actions work best sequentially to avoid data integrity issues.


6. Conclusion

Using Concurrent() in Power Apps greatly improves performance by executing multiple operations simultaneously. Whether you’re loading data sources, fetching API results, or optimizing app startup, Concurrent() reduces wait times and creates a faster, smoother user experience.

Would you like a specific implementation for SharePoint, SQL, or Dataverse?

Leave a Reply

Your email address will not be published. Required fields are marked *