Showing results for 
Search instead for 
Did you mean: 
samuelJ Responsive Resident
Responsive Resident

Set variable in forall

It looks like its not possible to set a variable in a forAll() loop.  Any way around this?


My overall problem is SQL Server API limitation.  I am running into too many records to patch for the 100 API calls per 10 seconds.  I wanted to try and create a large SQL statement and then run that with Flow.  


Within my forall() loop my plan was to append onto a string variable for each record in the collection.  


Thank you!VarInLoop.PNG

Community Support
Community Support

Re: Set variable in forall

Hi @samuelJ ,

Do you want to set a variable within a ForAll function?


Setting a variable within a ForAll function is not supported within PowerApps currently. If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:


As an alternative solution, I think collection could achieve your needs. On your side, you could consider use Collection to store the string value instead of the Set function. Please consider take a try with the following workaround:

       Collect(SQLStatementCollection, "abc")

If you want to concat these values within the SQLStatementCollection using a space (' '), please use the following formula (set Text property of a Label to following😞

Concat(SQLStatementCollection, Value & " ")


In addition, if you want to store the column value from your toUpdateSmall collection into the SQLStatementCollection, please modify above formula as below:

       Collect(SQLStatementCollection, ColumnNameFromtoUpdateSmall)

Please consider take a try with above solution, check if the issue is solved.


Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Frequent Visitor

Re: Set variable in forall

This would be extremely helpful to implement, as I was trying to use a ForAll last week to loop through the values in a collection to Set variables attached to the Default properties of various input text boxes, using Switch expressions.




     Switch (

          collectionName.key1 = val1, Set(defaultInput1, collectionName.key1),

          collectionName.key2 = val2, Set(defaultInput2, collectionName.key2),

          collectionName.key3 = val3, Set(defaultInput3, collectionName.key3)




I was attempting the above to load data from my collection into input text / numeric boxes in the OnVisible screen event so a user could read the previously saved data and be able to update it. I'm still looking for a workaround..

Helpful resources

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.


New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (7,834)