The ForAll function in Power Apps is used to perform a specific action or apply a formula to each record in a table or collection. It allows you to iterates over a set of data and execute an action for each item in that set, such as updating records, creating new ones, or performing calculations.
If the formula returns a record, the resulting table will include records with the same columns as those in the returned record.
If the formula returns a single value, the resulting table will be a single-column table. However, if the formula returns a record, the resulting table will include records with the same columns as the returned record.
If the result of the formula is a blank value, then there is no record in the result table for that input record.
Syntax:
ForAll(Table, Formula)
- Table: This is the table or collection of records you want to iterate through.
- Formula: The action or formula to be applied to each record.
When to use the ForAll:
- Conditional Actions: Perform actions on each record based on a condition.
- Bulk Updates: You can update multiple records at once instead of writing individual update statements.
- Bulk Insertions: You can insert multiple records into a data source in one go.
Here, we have a gallery called gal_emp that displays employee details. The gallery is connected to a SharePoint list called ‘Employee Info’.

Using ForAll function to update the mulitple records
Example 1: ForAll with Patch Function
Suppose you want to update the location to ‘Noida’ for all employees shown in the gallery. You can use the ForAll function along with Patch to update each record.
Add a Button control and named it ‘Update’, then go to OnSelect property of button and write a below formula.
ForAll(
 gal_emp.AllItems,
 Patch(
   'Employee Info',
   ThisRecord,
   {'Office Location': "Noida"}
 )
)
Lets understand the above formula:
- ForAll: Loops through all items in the gal_emp gallery.
- Patch: Updates records in the ‘Employee Info’ SharePoint list.
- LookUp: Finds the corresponding record in Employee Info by matching the ID from the gallery items.
- ThisRecord: Refers to the current record in the gallery being processed.
Now, you will see when you click on Update button. It updates the office location to “Noida” for all the records in the gallery.

Example2: Updating records based on conditions
Suppose, you want update specific records based on certain conditions.
Let’s modify the formula to update the Level to “L4” for all records in the gallery belonging to the “HR” department.

ForAll(
 Filter(
   gal_emp.AllItems,
   Department = "HR"
 ),
 Patch(
   'Employee Info',
   ThisRecord,
   {Level: "L4"}
 )
)
- The Filter function retrieves all items from gal_emp.AllItems where the Department is “HR”.
- The ForAll function iterates through each of the filtered records.
- For each record that meets the filter criteria, the Patch function updates the corresponding record in the ‘Employee Info’ data source, setting the Level to “L4”.

Example3: Updating records based on multiple conditionsÂ
Let’s add update the office location “Delhi” for all records belongs to “HR” department otherwise “Gurgaon”.
Go to the OnSelect property of Update button and write the below formula.
ForAll(
 gal_emp.AllItems,
 If(
   Department = "HR",
   Patch(
     'Employee Info',
     ThisRecord,
     {'Office Location': "Delhi"}
   ),
   Patch(
     'Employee Info',
     ThisRecord,
     {'Office Location': "Gurgaon"}
   )
 )
)


 key points to keep in mind when using the ForAll function in Power Apps:
- Delegation Limitations: The ForAll function is non-delegable, which means that when working with large data sources like SharePoint or SQL, only a limited number of records (by default, up to 2,000) can be processed. If you are dealing with large datasets, you’ll need to manage them in a different way.
- Â ForAll loops over each item in a table, which can slow down app performance if you use it on large tables or perform actions that require multiple server calls (such as updating records one by one).
Recommended for you
Reset multiple control values and all the controls within a form
Submit multiple records to a data source
![]()
