Concatenate and Concat is two handy functions in Power App that help us work with Strings. Though both may sound similar, they have different purposes and functionality.
Concatenate is used to combine a list of strings or a single column table into a single. It does not have the capability to work with complex data structures.
On the other hand, Concat can be used to work with tables and combine the values in one of the columns into a delimited single string. We can also use additional functions like a filter to get trimmed down a subset of the data while combining the table data.
In this article, we will see the usage of both Concat and Concatenate functions with some examples
Concatenate function provides the same functionality as combining strings using the & operator. Usage of a delimited is not mandatory, but if needed, based on the requirement we can add a delimiter like a comma to add more readability. Here we have concatenated 4 strings together without using any delimiter as we want to club together First Name, Last Name, City, and Country.
This is equivalent to the combining of strings using the & Operator
Now let’s try to step to the next level of concatenation where we will try to combine the rows from a table into a string. This time we will make a connection to the SharePoint list and returns the data which we will store in a collection. The SP List has the below schema and data
We will store it into a collection using the formula
|Collect(ListItems,ShowColumns(‘Travel Procurement List’,”ProcurementItem”,”ProcurementDate”,”Cost_x0028_USD_x0029_”));|
Now let’s see how we can use the Concat function to combine the Procurement Item column values as a comma-separated value in a text box control
|Concat(‘Travel Procurement List’,’Procurement Item’& “,”)|
Here we are using the Concat function to combine the values in the procurement items column and separating them with a comma and assigning it to the text box value
We can further apply filtering to show only those items whose cost is above 200 USD using the filter function in the expression
|Concat(Filter(‘Travel Procurement List’,’Cost(USD)’>200),’Procurement Item’& “,”)|
Same way, when we are working with the Concat function to combine and return unique values from SharePoint List, we can use the Distinct function to combine and remove the duplicates.
|Concat(Distinct(‘Travel Procurement List’,Department),Result&” ,”)|
Here we are applying Distinct and the output of the function is present in the variable Result which is then concatenated with a comma
So far, we saw how to combine the values of a single column in a table together. Now let’s see how we can combine the values from 2 columns together. Say for instance we want to Combine the Procured Item Name and Date together. We will use the Concatenate to stitch together the columns and Concat to combine the row values using the expression
|Concat(‘Travel Procurement List’,Concatenate(‘Procurement Item’& “(“&’Procurement Date’&”), “))|
Thus, we saw at a high level how to get started with Concat and Concatenate and also how to use them both together.