Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

6 Easiest Ways to Use Power Apps ForAll Function

As far as we know, Power Apps have various functions that make applications more attractive and responsive. One of the most useful controls among them is the Power Apps ForAll function.

In this Power Apps tutorial, I will explore what is the forall in PowerApps and its syntax; then, we will see how to use the ForAll function in Power Apps. Also, by taking some simple scenarios, We will cover all these below topics:

  • How to use Power Apps ForAll Collection
  • Working with Power Apps ForAll Set Variable
  • What is Power Apps ForAll Split
  • Power Apps ForAll Patch or Power Apps ForAll Patch SharePoint List
  • Power Apps ForAll Current Item

forall PowerApps

Power Apps ForAll() helps evaluate the formula and perform actions for all the records in a table. It evaluates some functionality on each row of a particular table/collection or database.

In the Power Apps ForAll function, the input and return values are the same. That means whatever you apply to the input value will return the same. If the return value is a bank value, there is no record in the result table. There may be fewer records in the result table than in the source table.

In the ForAll function in Power Apps, you can perform multiple operations using a separator (;). ForAll is not delegable while using the other functions, such as a Filter.

Note:

One important thing you should know is that some Power Apps functions like UpdateContext, ClearCollect, Clear, Remove, Set, etc., can hold the variable, which is vulnerable to the ordering issues for the for loop. So, we can not use these types of functions

Syntax of the Power Apps ForAll Function:

ForAll(Table, Formula)

Where,

  • Table = This is required to specify the table to be acted upon
  • Formula = This is also required that specifies the formula to evaluate all records of the Table

Power Apps ForAll Function Examples

In this example, we will see a simple calculation using the Squares data source.

Input:

forall in powerapps

To create the Data source as a Power Apps Collection, you can use the below formula on Apps’s OnStart property.

OnStart = ClearCollect(
    Squares,
    [
        "1",
        "4",
        "9"
    ]
forall powerapps

Insert a List box control on the Power Apps Screen and set its Items property to the code below.

Items = ForAll(
    Squares,
    Sqrt(Value)
)

OR

Sqrt( Squares )

Where,

  • Squares = Power Apps collection name

Output:

for all function in powerapps

For all the records of the input table, raise the Value column to the third power. The Power function does not support single-column tables. Therefore, the ForAll function must be used in this case.

To do so, follow the below code.

Items = ForAll(
    Squares,
    Power(
        Value,
        2
    )
)
forall function in powerapps

Power Apps ForAll Collection

In this example, I have used my collection, “Statements,” which has single-column table values.

power apps forall

To create the  Power Apps Collection, you can use the below formula on Apps’s OnStart property.

Onstart = ClearCollect(
    Statements,
    [
        "Goodmorning",
        "Goodbye",
        "Hello"
    ]
)
for all in powerapps

Now, on the Power Apps Screen, insert a Data table control and set its Items property to the code below.

Items = ForAll(
    Statements,
    MicrosoftTranslator.Translate(
        Value,
        "fr"
    )
)

Where,