Skip to content

Commit ee662c9

Browse files
committed
Edits
1 parent 319af26 commit ee662c9

File tree

3 files changed

+74
-65
lines changed

3 files changed

+74
-65
lines changed

powerapps-docs/maker/canvas-apps/functions/function-forall.md

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,45 @@ search.app:
1515
- PowerApps
1616
---
1717
# ForAll function in Power Apps
18-
Calculates values and performs actions for all [records](../working-with-tables.md#records) of a [table](../working-with-tables.md).
18+
19+
Calculates values and performs actions for all the [records](../working-with-tables.md#records) in a [table](../working-with-tables.md).
1920

2021
## Description
21-
The **ForAll** function evaluates a formula for all records of a table. The formula can calculate a value and/or perform actions, such as modifying data or working with a connection. Use the [**With** function](function-with.md) to evaluate a formula for a single record.
22+
23+
The **ForAll** function evaluates a formula for all the records if a table. The formula can calculate a value and/or perform actions, such as modifying data or working with a connection. Use the [**With** function](function-with.md) to evaluate the formula for a single record.
2224

2325
Use the [**Sequence** function](function-sequence.md) with the **ForAll** function to iterate based on a count.
2426

2527
[!INCLUDE [record-scope](../../../includes/record-scope.md)]
2628

2729
### Return value
30+
2831
The result of each formula evaluation is returned in a table, in the same order as the input table.
2932

30-
If the result of the formula is a single value, the resulting table will be a single column table. If the result of the formula is a record, the resulting table will contain records with the same columns as the result record.
33+
If the result of the formula is a single value, the resulting table will be a single-column table. If the result of the formula is a record, the resulting table contains records with the same columns as the result record.
3134

32-
If the result of the formula is a *blank* value, then there will be no record in the result table for that input record. In this case, there will be fewer records in the result table than the source table.
35+
If the result of the formula is a *blank* value, then there is no record in the result table for that input record. In this case, there will be fewer records in the result table than the source table.
3336

3437
### Taking action
38+
3539
The formula can include functions that take action, such as modifying the records of a data source with the **[Patch](function-patch.md)** and **[Collect](function-clear-collect-clearcollect.md)** functions. The formula can also call methods on connections. Multiple actions can be performed per record by using the [**;** operator](operators.md). You can't modify the table that is the subject of the **ForAll** function.
3640

37-
When writing your formula, keep in mind that records can be processed in any order and, when possible, in parallel. The first record of the table may be processed after the last record. Take care to avoid ordering dependencies. For this reason, you can't use the **[UpdateContext](function-updatecontext.md)**, **[Clear](function-clear-collect-clearcollect.md)**, and **[ClearCollect](function-clear-collect-clearcollect.md)** functions within a **ForAll** function because they could easily be used to hold variables that would be susceptible to this effect. You can use **[Collect](function-clear-collect-clearcollect.md)**, but the order in which records are added is undefined.
41+
When writing your formula, keep in mind that records can be processed in any order and, when possible, in parallel. The first record of the table may be processed after the last record.
42+
43+
Take care to avoid ordering dependencies. For this reason, you can't use the **[UpdateContext](function-updatecontext.md)**, **[Clear](function-clear-collect-clearcollect.md)**, and **[ClearCollect](function-clear-collect-clearcollect.md)** functions within a **ForAll** function because they could easily be used to hold variables that would be susceptible to this effect. You can use **[Collect](function-clear-collect-clearcollect.md)**, but the order in which records are added is undefined.
3844

39-
Several functions that modify data sources, including **Collect**, **Remove**, and **Update**, return the changed data source as their return value. These return values can be large and consume significant resources if returned for every record of the **ForAll** table. You may also find that these return values are not what you expect, because **ForAll** can operate in parallel and may separate the side effects of these functions from obtaining their result. Fortunately, if the return value from **ForAll** is not actually used, which is often the case with data modification functions, then the return value will not be created and there are no resource or ordering concerns. But if you are using the result of a **ForAll** and one of the functions that returns a data source, think carefully about how you structure the result and try it out first on small data sets.
45+
Several functions that modify data sources, including **Collect**, **Remove**, and **Update**, return the changed data source as their return value. These return values can be large and consume significant resources if returned for every record of the **ForAll** table. You may also find that these return values are not what you expect because **ForAll** can operate in parallel and may separate the side effects of these functions from obtaining their result. If the return value from **ForAll** is not used, which is often the case with data modification functions, then the return value will not be created and there are no resource or order concerns. But if you are using the result of a **ForAll** and one of the functions that returns a data source, think carefully about how you structure the result and try it out first on small data sets.
4046

4147
### Alternatives
42-
Many functions in Power Apps can process more than one value at a time through the use of a single-column table. For example, the **Len** function can process a table of text values, returning a table of lengths, in the same manner that **ForAll** could. This can eliminate the need to use **ForAll** in many cases, can be more efficient, and is easier to read.
48+
Many functions in Power Apps can process more than one value at a time through the use of a single-column table. For example, the **Len** function can process a table of text values, returning a table of lengths, in the same manner, that **ForAll** could. This can eliminate the need to use **ForAll** in many cases, can be more efficient, and is easier to read.
4349

4450
Another consideration is that **ForAll** is not delegable while other functions may be, such as **Filter**.
4551

4652
### Delegation
4753
[!INCLUDE [delegation-no-one](../../../includes/delegation-no-one.md)]
4854

4955
## Syntax
50-
**ForAll**( *Table*, *Formula* )
56+
**ForAll**(*Table*, *Formula*)
5157

5258
* *Table* - Required. Table to be acted upon.
5359
* *Formula* - Required. The formula to evaluate for all records of the *Table*.
@@ -58,7 +64,7 @@ The following examples use the **Squares** [data source](../working-with-data-so
5864

5965
![](media/function-forall/squares.png)
6066

61-
To create this data source as a collection, set the **OnSelect** property of a **Button** control to this formula, open Preview mode, and then click or tap the button:
67+
To create this data source as a collection, set the **OnSelect** property of a **Button** control to this formula, open Preview mode, and then select the button:
6268

6369
`ClearCollect( Squares, [ "1", "4", "9" ] )`
6470

@@ -72,33 +78,33 @@ The following examples use the **Expressions** [data source](../working-with-dat
7278

7379
![](media/function-forall/translate.png)
7480

75-
To create this data source as a collection, set the **OnSelect** property of a **Button** control to this formula, open Preview mode, and then click or tap the button:
81+
To create this data source as a collection, set the **OnSelect** property of a **Button** control to this formula, open Preview mode, and then select the button:
7682

7783
`ClearCollect( Expressions, [ "Hello", "Good morning", "Thank you", "Goodbye" ] )`
7884

79-
This example also uses a [Microsoft Translator](../connections/connection-microsoft-translator.md) connection. To add this connection to your app, see the topic about how to [manage connections](../add-manage-connections.md).
85+
This example also uses a [Microsoft Translator](../connections/connection-microsoft-translator.md) connection. To add this connection to your app, see the article about how to [manage connections](../add-manage-connections.md).
8086

8187
| Formula | Description | Result |
8288
| --- | --- | --- |
83-
| **ForAll( Expressions, MicrosoftTranslator.Translate( Value, "es" ) )** |For all the records in the Expressions table, translate the contents of the **Value** column into Spanish (abbreviated "es"). | ![](media/function-forall/translate-es.png) |
84-
| **ForAll( Expressions, MicrosoftTranslator.Translate( Value, "fr" ) )** |For all the records in the Expressions table, translate the contents of the **Value** column into French (abbreviated "fr"). | ![](media/function-forall/translate-fr.png) |
89+
| **ForAll(Expressions, MicrosoftTranslator.Translate( Value, "es"))** |For all the records in the Expressions table, translate the contents of the **Value** column into Spanish (abbreviated "es"). | ![](media/function-forall/translate-es.png) |
90+
| **ForAll(Expressions, MicrosoftTranslator.Translate( Value, "fr"))** |For all the records in the Expressions table, translate the contents of the **Value** column into French (abbreviated "fr"). | ![](media/function-forall/translate-fr.png) |
8591

8692
### Copying a table
87-
Sometimes you need to filter, shape, sort, and manipulate data. Power Apps provides a number of functions for doing this, such as **Filter**, **AddColumns**, and **Sort**. Power Apps treats each table as a value, allowing it to flow through formulas and be consumed easily.
93+
Sometimes you need to filter, shape, sort, and manipulate data. Power Apps provides many functions for doing this, such as **Filter**, **AddColumns**, and **Sort**. Power Apps treat each table as a value, allowing it to flow through formulas and be consumed easily.
8894

89-
And sometime you will want to make a copy of this result for later use. Or you will want to move information from one data source to another. Power Apps provides the **Collect** function to copy data.
95+
And sometimes you want to make a copy of this result for later use, or you want to move information from one data source to another. Power Apps provides the **Collect** function to copy data.
9096

91-
But before you make that copy, think carefully if it is really needed. Many situations can be addressed by filtering and shaping the underlying data source on demand with a formula. Some of the downsides to making a copy include:
97+
But before you make that copy, think carefully if it is needed. Many situations can be addressed by filtering and shaping the underlying data source on-demand with a formula. Some of the downsides to making a copy include:
9298

93-
* Two copies of the same information means that one of them can fall out of sync.
94-
* Making a copy can consume a lot of computer memory, network bandwidth, and/or time.
99+
* Two copies of the same information mean that one of them can fall out of sync.
100+
* Making a copy can consume much of the computer memory, network bandwidth, and/or time.
95101
* For most data sources, copying cannot be delegated, limiting how much data can be moved.
96102

97103
The following examples use the **Products** [data source](../working-with-data-sources.md):
98104

99105
![](media/function-forall/prod.png)
100106

101-
To create this data source as a collection, set the **OnSelect** property of a **Button** control to this formula, open Preview mode, and then click or tap the button:
107+
To create this data source as a collection, set the **OnSelect** property of a **Button** control to this formula, open Preview mode, and then select the button:
102108

103109
```powerapps-dot
104110
ClearCollect( Products,
@@ -134,7 +140,7 @@ ShowColumns(
134140

135141
A [record scope](../working-with-tables.md#record-scope) is created by the **Filter** and **AddColumns** functions to perform the comparison and subtraction operations, respectively, with the **'Quantity Requested'** and **'Quantity Available'** fields of each record.
136142

137-
In this example, the **Filter** function can be delegated. This is important, as it can find all the products that meet the criteria, even if that is only a few records out of a table of millions. At this time, **ShowColumns** and **AddColumns** cannot be delegated, so the actual number of products that needs to be ordered will be limited. If you know the size of this result will always be relatively small, this approach is fine.
143+
In this example, the **Filter** function can be delegated. This is important, as it can find all the products that meet the criteria, even if that is only a few records out of a table of millions. At this time, **ShowColumns** and **AddColumns** cannot be delegated, so the actual number of products that need to be ordered will be limited. If you know the size of this result will always be relatively small, this approach is fine.
138144

139145
And because we didn't make a copy, there is no additional copy of the information to manage or fall out of date.
140146

@@ -154,7 +160,7 @@ ForAll( Products,
154160

155161
This formula may be simpler for some people to read and write.
156162

157-
No part of the **ForAll** is delegable. Only the first portion of the **Products** table will be evaluated, which could be a problem if this table is very large. Because **Filter** could be delegated in the previous example, it could work better with large data sets.
163+
No part of the **ForAll** is delegable. Only the first portion of the **Products** table will be evaluated, which could be a problem if this table is large. Because **Filter** could be delegated in the previous example, it could work better with large data sets.
158164

159165
#### Collect the result
160166
In some situations, a copy of data may be required. You may need to move information from one data source to another. In this example, orders are placed through a **NewOrder** table on a vendor's system. For high-speed user interactions, you may want to cache a local copy of a table so that there is no server latency.
@@ -187,7 +193,7 @@ ClearCollect( NewOrder,
187193
)
188194
```
189195

190-
**ClearCollect** and **Collect** can't be delegated. As a result the amount of data that can be moved in this manner is limited.
196+
**ClearCollect** and **Collect** can't be delegated. As a result, the amount of data that can be moved in this manner is limited.
191197

192198
#### Collect within ForAll
193199
Finally, we can perform the **Collect** directly within the **ForAll**:
@@ -208,5 +214,5 @@ ForAll( Products,
208214

209215
Again, the **ForAll** function can't be delegated at this time. If our **Products** table is large, **ForAll** will look at the first set of records only and we may miss some products that need to be ordered. But for tables that we know will remain small, this approach is fine.
210216

211-
Note that we are not capturing the result of the **ForAll**. The **Collect** function calls made from within it will return the **NewOrder** data source for all the records, which could add up to a lot of data if we were capturing it.
217+
Note that we are not capturing the result of the **ForAll**. The **Collect** function calls made from within it will return the **NewOrder** data source for all the records, which could add up to numerous data if we were capturing it.
212218

powerapps-docs/maker/canvas-apps/functions/function-sequence.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ The number of records to generate is rounded down to the nearest whole number an
5050

5151
| Formula | Description | Result |
5252
| --- | --- | --- |
53-
| **Sequence( 4 )** | Generates a 4 record table starting at the default 1 and incrementing by the default 1. | ![](media/function-sequence/sequence-4.png) |
54-
| **Sequence( 4, 24 )** | Generates a 4 record table starting at 24 and incrementing by the default 1. | ![](media/function-sequence/sequence-4-24.png) |
55-
| **Sequence( 4, 4, -1 )** | Generates a 4 record table starting at 4 and incrementing by -1, effectively counting backward. | ![](media/function-sequence/sequence-4-4-n1.png) |
56-
| **Sequence( 4, -100, 0.5 )** | Generates a 4 record table starting at -100 and incrementing by 0.5. | ![](media/function-sequence/sequence-4-n100-p5.png) |
57-
| **Sequence( 0.9 )** | Generates an *empty* table as the count rounds down to 0. | ![](media/function-sequence/sequence-empty.png) |
58-
| **ForAll( Sequence( 4 ), Rand() )** | Generates a 4 record table of random numbers. | ![](media/function-sequence/sequence-4-random.png)<br>*Actual numbers will vary.* |
53+
| **Sequence( 4 )** | Generates a 4 record table starting at the default 1 and incrementing by the default 1. | ![Sequence-4](media/function-sequence/sequence-4.png "Sequence-4") |
54+
| **Sequence( 4, 24 )** | Generates a 4 record table starting at 24 and incrementing by the default 1. | ![Sequence-4-24](media/function-sequence/sequence-4-24.png "Sequence-4-24") |
55+
| **Sequence( 4, 4, -1 )** | Generates a 4 record table starting at 4 and incrementing by -1, effectively counting backward. | ![Sequence-4-4-n1](media/function-sequence/sequence-4-4-n1.png "Sequence-4-4-n1") |
56+
| **Sequence( 4, -100, 0.5 )** | Generates a 4 record table starting at -100 and incrementing by 0.5. | ![Sequence-4-n100-p5](media/function-sequence/sequence-4-n100-p5.png "Sequence-4-n100-p5") |
57+
| **Sequence( 0.9 )** | Generates an *empty* table as the count rounds down to 0. | ![Sequence-empty](media/function-sequence/sequence-empty.png"Sequence-empty") |
58+
| **ForAll( Sequence( 4 ), Rand() )** | Generates a 4 record table of random numbers. | ![sequence-4-random](media/function-sequence/sequence-4-random.png"Sequence-4-random")<br>*Actual numbers will vary.* |
5959
| **Concat( Sequence( 5 ),<br>Text( Value ) & " " )** | Generates a string of numbers from 1 to 5. | **"1 2 3 4 5 "** |
6060

6161
### Character map

0 commit comments

Comments
 (0)