A few days ago, I developed an employee leave management application. To generate a unique request ID, I was required to concatenate the employee name with the current date in a text format. Also, I need to notify the employee by their name when submitting the leave request. I achieved all these requirements with different approaches in Power Apps by concatenating the text strings.
This article will explain how to concatenate text strings in Power Apps using three methods.
Concatenate Text Strings In Power Apps
In Power Apps, we have many approaches to concatenating two strings; the approaches are
- Concatenate () function
- Using & operator
- String interpolation $”{expression}”
Concatenate Text Strings In Power Apps [Using Concatenate Function]
The Concatenate function in Power Apps allows the combination of two or more text strings into one. It also combines a column table of strings. Let’s see the syntax:
Concatenate( String1 [, String2, ...] )
- String(s) = Required, it combines the strings into one.
Example 1: Display the welcome message by concatenating the current user name and the welcome text with the Power Apps concatenate function.
Concatenate("Hello, ", User().FullName, "! Welcome to Leave Management Application.")
Here, we concatenated three strings. In the image below, you can see the concatenated text.
Example 2: Generate a unique request ID by concatenating the employee email and current date in text format.
I have a SharePoint List named Employee Leave Requests with the following columns.
Column Name | Data Type |
---|---|
Leave Title | Single line of text |
Leave Type | Choice(Annual Leave,Sick Leave,Vacation Leave) |
Employee Name | Person |
Request ID | Single line of text |
Department | Choice(IT,HR,Marketing,Finance) |
Start Date | Date&Time |
End Date | Date&Time |
Manager Name | Single line of text |
1. Provide the below formula in the Default property of the Request ID data card value in Power Apps form control.
Concatenate(Left(cmb_Employee.Selected.Email,Find("@",cmb_Employee.Selected.Email)-1),"_",Text(Now(),"yyyymmdd"))
Here,
- cmb_Employee = Combo box control, which contains employee names.
- Find() = It finds the “@” from the combo box selected employee email.
- Left() = Fetches the text present on the left side of “@.”
- Now() = Returns current date.
- Text() = Converts the current date as “yyyymmdd.”
The concatenate function combines the three strings: prefix of employee email and current date, in between underscores of “_.”
2. In the image below, you can see that the Request ID is created dynamically when I select the employee name according to that.
Example 3: Notify the employee with his name and manager’s name while submitting.
1. Add this formula to the OnSelect property of the submit button control.
SubmitForm(frm_EmpLeave);
Notify(
Concatenate("Hi ",cmb_Employee.Selected.DisplayName,", your leave request succesfully submitted to you manager",txt_managername.Text),
NotificationType.Success
);
NewForm(frm_EmpLeave);
here,
- cmb_Employee = Combo box name that contains employee names.
- txt_managername = Text input control name that stores manager name.
Within the Notify() function we’re concatinating the notify message along with employee name and manager name.
2. Now, look at the output image below while submitting the leave request.
Concatenate Text Strings In Power Apps [Using & Operator]
The & operator in Power Apps is a shortened for concatenate function. We’ll mostly use this operator to concatenate small sentences. Let’s look at examples of using this Power Apps & operator to concatenate text strings.
Example 1: Concatenate the employee name with the label and icon using & operator.
I have a Power Apps gallery, which displays details of employee travel requests. In order to make it more understandable and attractive, I concatenated the employee names with “Employee Name: 👤” text.
Add this code to the Text property of the employee name label in the Power Apps gallery control.
"Employee Name: 👤"&ThisItem.Title
Here, the & operator concatenates both strings. You can use the same code for the remaining fields in the gallery control.
Example 2: Concatenate start and end dates with “Travel Dates” text, “-” and date icon.
Here, instead of displaying start and end dates on different labels in the Power Apps gallery, I concatenated the two dates along with date icons and between the dates “-” for better understanding.
"Travel Dates: 📅" & ThisItem.StartDate & " - 📅" &ThisItem.EndDate
This way, we can use Power Apps & operator for concatenating multiple texts into a single sentence.
Concatenate Text Strings In Power Apps [Using String Interpolation $”{expression}”]
In Power Apps, we use this $ “{}” approach to concatenate strings with expressions. We can get the dynamic values within the curly braces {} by providing formulas over there.
Syntax:
$"{expression}
With this approach, let’s see some examples of concatenating text strings in Power Apps.
Example 1: Concatenate the text with dynamic values in Power Apps using the $” ” approach.
$"Hello {User().FullName}, you have {CountRows(Gal_TravelAuthorization.AllItems)} travel requests waiting for approvals."
Here,
- User().FullName = Returns current logged-in user name.
- Gal_TravelAuthorization = Gallery name.
- CountRows() returns the number of items present in the gallery.
The $”” concatenates the text with dynamic values.
Example 2: Display the description dynamically by concatenating the employee name with the start date and with some description text.
$"Travel request for {ThisItem.Title} to {ThisItem.Destination} is scheduled on {Text(ThisItem.StartDate, "dddd, mmmm dd, yyyy")}."
Here,
- ThisItem.Title = Returns employee name.
- ThisItem.Destination = Returns destination.
- ThisItem.StartDate = Returns start date.
- Text() = Converts date into “dddd, mmmm dd, yyyy” format.
The $” ” concatenating description text with dynamic text returning from the formula ThisItem.Title, destination, start date.
This way, we can concatenate multiple texts in Power Apps with the $” ” approach.
I hope you understand how to concatenate text strings in Power Apps. In this article, I explained three approaches with different examples for each approach. You can follow these examples and change them according to your requirements.
Also, you may like:
- Create a Dropdown With Other Option in Power Apps
- Power Apps now today and istoday functions
- Date format in Power Appa data table
- Power Apps gallery control examples
- Power Apps filter gallery by date
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com