Latest Posts

PowerApps - Concurrent function with examples


In this article, we are going to go through the details about PowerApps Concurrent function. Concurrent is a very useful function especially when you want to achieve performance improvement in your PowerApps application. Let’s understand in detail, how and where you can use the concurrent function using some examples.

Note:

  • Definition: Concurrent means multiple events/actions/tasks happening in parallel.
    • For PowerApps, the Concurrent function enables us to run multiple formulas parallelly.
  • If we want to execute multiple formulas parallelly, we can use Concurrent function
  • In PowerApps if you want to execute multiple formulas in a sequence, then you can separate all the formulas with a semicolon (;), but what if you want to execute them all in parallel – at the same time.
  • At the time of Page Load, instead of using multiple formulas with a semicolon (;), you can get data from multiple tables using Concurrent, which will certainly reduce the overall load time of the screen.
  • Sequence order is not defined in which the formulas within Concurrent will Start and End.
  • No formula should have a dependency on each other within the Concurrent function.
  • The concurrent function can have a dependency on the output of the other functions used outside (Concurrent function).
  • The other formulas outside of the Concurrent function can also take values from the Concurrent function.
  • Concurrentfunction can be used only in behavior formulas.
  • Although it is not going to make much difference if you use the concurrent function in setting the variables, if you are doing multiple PATCH or UPDATE on tables that are completely independent then, you will notice a good amount of performance improv

PowerApps Concurrent function Syntax

Concurrent(Formula1,Formula2[, ...] )

  • Formula(s): This is required.
    • This is the formulas to be used withing Concurrent function.
    • You need to at least specify 2 formulas.

PowerApps Concurrent Functions Examples

  • Using the Concurrent function in your PowerApps application is very easy.
  • Here, we are creating 4 collections with 4 different tables from CDS.
  • Concurrent(

        ClearCollect(

            tempWeathers,

            Weathers

        ),

        ClearCollect(

            tempParcels,

            Parcels

        ),

        ClearCollect(

            tempProducts,

            ProductMasters

        ),

        ClearCollect(

            tempUser,

            Users

        )

    )

  • All the collections are created, and they don’t have any interdependencies.
  • We can use Concurrent at the time of page load in order to the same load time of the screen.

PowerApps Concurrent – Performance check using the example

  • Let’s see the performance of the above example.
  • Just to remind, in the above example, we are creating 4 collections parallelly using the Concurrent function.
  • In the above code. When the page loads, PowerApps starts creating all the 4 collections parallelly.
  • Please find the picturization of the same in-browser developer tools – Network tab.
  • The graph clearly shows that all the four executions started almost at the same time, obviously end time will vary a lot because of the volume of the data in each table
  • Total Time is taken for creating 4 collections – 1483 ms
  • powerapps concurrent
  • Let’s create 4 collections in a sequential manner.
  • ClearCollect(

            tempWeathers,

            Weathers

        );

        ClearCollect(

            tempParcels,

            Parcels

        );

        ClearCollect(

            tempProducts,

            ProductMasters

        );

        ClearCollect(

            tempUser,

            Users

        )

  • In the above code. When the first collection is created then only PowerApps goes to create the second collection and the same way for the third and fourth.
  • Please find the picturization of the same in-browser developer tools – Network tab.
  • The graph clearly shows that the next executions start only after one execution finishes.
  • Total Time is taken for creating 4 collections – 2084 ms
  • powerapps sequential

PowerApps Concurrent – Sequential function within Concurrent

  • You can also add sequential formula within the Concurrent function using a semicolon (;).
  • powerapps concurrent formula
  • Refer to the formula above.
  • First 2 formulas are in sequence.
    • They are separated by a semicolon (;).
    • Once VarFirst is set then only VarSecond will be set.
    • You can see VarFirst is used in varSecond so obviously they both cannot run in parallel because the second function has the dependency on the first one.
    • The same way varThird and varFourth are run in sequence because VarFourth has a dependency.
  • Now, the first 2 variables (varFirst and varSecond) and the last 2 variables (varThird and varFourth) don’t have any dependencies on each other, so they can run parallelly.
  • The same way you can also design your logic the way that no interdependent formulas are put in sequential execution.

We value your Feedback:

Page URL:

Name:

 

Email:

 
 

Suggestion:

 

© 2024 Code SharePoint