Concat Function in Power Apps

The Concat function in Power Apps is what allows you to combine values from a table or collection into a single string.

Unlike Concatenate, which joins individual strings, Concat works directly with tables and collections.

Syntax

The basic syntax of the Concat function is:

Concat( Table, Formula, Separator )

  • Table: The data source, which can be a table or collection.
  • Formula: The expression applied to each record (e.g., Name or Row).
  • Separator: The character(s) used to separate values (e.g., comma, carriage return).

Example with a Table

Let’s start by creating a table variable in the OnStart property of the app:

Set( teamTable, Table( {Name:"Alice", Row:"Manager"}, {Name:"Bob", Row:"Recruiter"} ) )

Next, insert a gallery and set its Items property to teamTable. This displays the data in the app. Below the gallery, add a text label and use the Concat function:

Concat( teamTable, Name & " " & Row & Char(10) )

Here, each record’s Name and Row are concatenated, separated by a carriage return (Char(10)), so they appear on separate lines.

Using a Collection

Collections can also be used with Concat since they are table data types. For example:

ClearCollect( teamCollection, {Name:"Pat"}, {Name:"Jessica"}, {Name:"David"}, {Name:"Karen"} )

After running OnStart, set a gallery’s Items property to teamCollection. Then, add a text label with:

Concat( teamCollection, Name & Char(10) )

This will display all names from the collection in a single string, each on a new line.

Filtering Data Before Concatenation

You can filter the collection before applying Concat. For example:

Concat( Filter(teamCollection, Row = "Recruiter"), Name & Char(10) )

This will only concatenate the names of team members whose Row equals Recruiter.

Concat vs Concatenate

It’s important not to confuse Concat with Concatenate:

  • Concatenate: Joins individual strings together.
  • Concat: Joins values from all records in a table or collection into a single string.

Conclusion

The Concat function is extremely useful when you need to display or process multiple values from a table or collection as one string.

Whether you’re working with variables, collections, or filtered datasets, Concat provides flexibility and efficiency in Power Apps.

Comments

Leave a Comment

Your email address will not be published. Required fields are marked *