Concat and Concatenate functions
Applies to: Canvas apps Dataverse formula columns Desktop flows Model-driven apps Power Pages Power Platform CLI
Concatenates individual strings of text and strings in tables.
Description
The Concatenate function concatenates a mix of individual strings and a single-column table of strings. When you use this function with individual strings, it's equivalent to using the & operator.
The Concat function concatenates the result of a formula applied across all the records of a table, resulting in a single string. Use this function to summarize the strings of a table, just as the Sum function does for numbers.
Fields of the record currently being processed are available within the formula. Use the ThisRecord operator or simply reference fields by name as you would any other value. The As operator can also be used to name the record being processed which can help make your formula easier to understand and make nested records accessible. For more information, see the examples below and working with record scope.
Use the Split or MatchAll function to split a string into a table of substrings.
Syntax
Concat( Table, Formula, separator)
- Table - Required. Table to operate on.
- Formula - Required. Formula to apply across the records of the table.
- Separator - Optional. A text value to be inserted between concatenated rows of the table.
Concatenate( String1 [, String2, ...] )
- String(s) - Required. Mix of individual strings or a single-column table of strings.
Examples
The examples in this section use these global variables:
- FirstName = "Jane"
- LastName = "Doe"
- Products =
To create these global variables in an app, insert a Button control, and set its OnSelect property to this formula:
Set( FirstName, "Jane" ); Set( LastName, "Doe" );
Set( Products,
Table(
{ Name: "Violin", Type: "String" },
{ Name: "Cello", Type: "String" },
{ Name: "Trumpet", Type: "Wind" }
)
)
Select the button (by clicking it while you hold down the Alt key).
Concatenate function and the & operator
For these examples, set the Text property of a Label control to a formula from the first column of the next table.
Formula | Description | Result |
---|---|---|
Concatenate( LastName, ", ", FirstName ) | Concatenates the value in LastName, the string ", " (a comma followed by a space), and the value in FirstName. | "Doe, Jane" |
LastName & ", " & FirstName | Same as the previous example except using the & operator instead of the function. | "Doe, Jane" |
Concatenate( FirstName, " ", LastName ) | Concatenates the value in FirstName, the string " " (a single space), and the value in LastName. | "Jane Doe" |
FirstName & " " & LastName | Same as the previous example, using the & operator instead of the function. | "Jane Doe" |
Concatenate with a single-column table
For this example, add a blank, vertical Gallery control, set its Items property to the formula in the next table, and then add a label in the gallery template.
Formula | Description | Result |
---|---|---|
Concatenate( "Name: ", Products.Name, ", Type: ", Products.Type ) | For each record in the Products table, concatenates the string "Name: ", the name of the product, the string ", Type: " and the type of the product. | A single-column table with a Value column containing the following values: "Name: Violin, Type: String", "Name: "Cello, Type: String", "Name: Trumpet, Type: Wind" |
Concat function
For these examples, set the Text property of a label to a formula from the first column of the next table.
Formula | Description | Result |
---|---|---|
Concat( Products, Name, ", " ) | Evaluates the expression Name for each record of Products and concatenates the results together into a single text string separated by ", ". | "'Violin', 'Cello', 'Trumpet'" |
Concat( Products, "'" & Name & "'", ", " ) | Evaluates the expression "'" & Name & "'" for each record of Products and concatenates the results together into a single text string separated by ", ". | "'Violin', 'Cello', 'Trumpet'" |
Concat( Filter( Products, Type = "String" ), Name, ", " ) | Evaluates the formula Name for each record of Products that satisfies the filter Type = "String", and concatenates the results into a single text string separated by ", ". | "Violin, Cello" |
Split and MatchAll
If you used Concat with a separator, you can reverse the operation by using the Split function.
For these examples, add a blank, vertical gallery, set its Items property to a formula in the next table, and then add a label in the gallery template.
Formula | Description | Result |
---|---|---|
Split( Concat( Products, Name, ", " ), ", " ) | Splits the text string with the separator ", ". | A single-column table with a Value column containing the following values: "Violin", "Cello", "Trumpet" |