top menu gradient

Example of DO() and DO_PARALLEL()

The DO() function is used to run multiple cells one by one, and the DO_PARALLEL() function is used to run multiple cells simultaneously.

The following example shows how the DO() and DO_PARALLEL() functions work and so that you better understand when to use them. This example uses the REST API service https://reqres.in to which multiple requests are sent from a range of cells.

This example doesn't show how to use the DO() and DO_PARALLEL() functions in a design, it just shows how they work in principle. In practice, when you define the behavior of your application, you link a user action, such as a mouse click or a keystroke, to running an action cell with DO() or DO_PARALLEL() function (you can see an example of such a usage here)

  1. Enter numbers from 1 to 7 in into a vertical range of cells, like so:

    AB
    11
    22
    33
    44
    55
    66
    77
  2. In another vertical range of 7 cells, enter the formula shown below. It's a nested formula whose execution takes long enough so that you are able to note the difference between sequential and simultaneous execution. Each cell must be an action cell. Each formula in the action cells must include the reference to the respective number in the numbered range.

    AB
    11=?POST("https://reqres.in/api/users",JSON(GRAB(GET("https://reqres.in/api/users/" & A1),"$..data")))
  3. In an empty cell, enter the DO() function with the reference to the action-cell range as the argument.

  4. In an empty cell, enter the DO_PARALLEL() function with the reference to the action-cell range as the argument.

Compare the way the DO() and DO_PARALLEL() functions work by clicking the respective cells.

Note that when the DO() function is used, cells are evaluated one by one, and when the DO_PARALLEL function is used, cells are evaluated all at once.

Contents