Do you need to get the first word in string using Power Automate? Then, this Power Automate tutorial will help you to get first word in a String using Power Automate. Also, I have covered:
- Power Automate Get Last Word in String
- Power Automate Split String Get First
Scenario:
Recently, I got a requirement to get the first word in string using Power Automate flow; for example:
Input String Value: Hello World
Once we get the first word in string value using the first() function, The expected value looks like below:
Output String Value: Hello
Power Automate Get First Word in String
Let us see how to get the first word in a string in Power Automate flow
Example -1:
In this example, I’ll show you how to get the first name of the user display name using flow,
Step-1:
Create an instant cloud flow with a manual trigger, Add a new step, and choose the Get my profile (V2) action to get the user details.
By default, it retrieves all the details of my profile.
Step-2:
Add a compose data operation and use the below expression, which gets the display name and splits the value by using the first() function. It returns the first name of the display name
first(split(body('Get_my_profile_(V2)')?['displayName'],' '))
Step-3:
Add a send an email (V2) action to send an email with the first name of the user display name, Pass the required parameters
- To – From the dynamic content, select the user email address
- Subject – Enter the subject of the mail
- Body – Enter the body of the mail, Pass the output of the above-composed data operation, which has only the first name of the user display name.
outputs('First Name')
Step-4:
save and run the flow by selecting the run flow option; once the flow runs successfully, we can see it gets the first name of the user display name.
In Outlook, we also received an email only with the first name of the user display name.
This is how to get the first word in a string in Power Automate flow.
Example -2:
In this example, I’ll show you how to get the first name of the Employee name field presented in the SharePoint list using flow.
Here I am going to use the below Employees SharePoint list, consisting of
Column Name | Column Type |
EmployeeID | default title column |
EmployeeName | People or Group column |
EmployeeDesignation | Text column |
Step-1:
Create an Automate cloud flow with a When an item is created trigger, Expand the trigger action and configure the required parameters
- Site Address – Configure the SharePoint site address
- List Name – select the SharePoint list name (here I have selected the Employee SharePoint list)
Step-2:
Add a compose data operation, to get the employee name from the SharePoint list Employee Name field for the newly created item.
triggerOutputs()?['body/EmployeeName/DisplayName']
Step-3:
Add another compose data operation, and use the below expression to get the first name of the Employee Name.
first(split(outputs('EmployeeName'),' '))
Step-4:
Add a send an email (V2) action to send an email with the first name of the employee name, Pass the required parameters
- To – From the dynamic content, select the user email address (I have passed the Employee Name Email Address)
- Subject – Enter the subject of the mail
- Body – Enter the body of the mail and pass the output of the above-composed data operation, which has only the first name of the user display name.
outputs('FirstName')
Step-5:
save and run the flow by selecting the run flow option; The flow triggers when a new item is created in the SharePoint list; here, I have created the below highlighted SharePoint list item.
Once the flow runs successfully in Outlook, we receive an email only with the first name of the employee name created in the SharePoint list.
This is how to get the first word in a string in Power Automate flow.
Power Automate Get Last Word in String
Example -1:
In this example, I’ll show you how to get the last name of the user display name using flow,
Step-1:
Create an instant cloud flow, Add a new step, and choose the Get my profile (V2) action to get the user details.
Step-2:
Add a compose data operation and use the below expression, which gets the display name and splits the value by using the last() function which returns the first name of the display name.
last(split(body('Get_my_profile_(V2)')?['displayName'],' '))
Step-3:
Add a send an email (V2) action to send an email with the last name of the user display name, Pass the required parameters
- To – From the dynamic content, select the user email address
- Subject – Enter the subject of the mail
- Body – Enter the body of the mail, Pass the output of the above-composed data operation, which has only the last name of the user display name.
Step-4:
save and run the flow by selecting the run flow option; once the flow runs successfully, we can see it gets the last name of the user display name.
In Outlook, we also received an email only with the last name of the user display name.
This is how to get the last word in a string in Power Automate flow.
Example -2:
Also, in this example, I am going to use the Employee SharePoint list to get the last word in an Employee Name field using Power Automate flow
Step-1:
Create an Automate cloud flow with a When an item is created trigger, Expand the trigger action and configure the required parameters
- Site Address – Configure the SharePoint site address
- List Name – select the SharePoint list name (here I have selected the Employee SharePoint list)
Step-2:
Add a compose data operation to get the employee name from the SharePoint list Employee Name field for the newly created item.
triggerOutputs()?['body/EmployeeName/DisplayName']
Step-3:
Add another compose data operation, and use the below expression to get the last name of the Employee Name.
last(split(outputs('EmployeeName'),' '))
Step-4:
Add a send an email (V2) action to send an email with the last name of the user display name; enter the details of the required parameters
- To – select the user email address from the dynamic content
- Subject – Enter the subject of the mail
- Body – Enter the body of the mail, Pass the output of the above-composed data operation, which has only the last name of the user display name.
outputs('LastName')
Step-5:
save and run the flow by selecting the run flow option. The flow triggers when an item is created in the SharePoint list. I have created the highlighted item below. (Here, for testing purposes, I am using my profile name.)
Once the flow runs successfully, In Microsoft Outlook, we receive an email only with the last name of the Employee Name for the newly created item in the SharePoint list.
This is how to get the last word in a string using Power Automate flow.
Power Automate Split String Get First
Let us see how to split the input string value and get the first word in the Power Automate flow
Step-1:
Create an instant cloud flow with a manual trigger, Add a text input for the input String as shown below:
Step-2:
Add a compose data operation to split the input string value; for that, use the below expression.
split(triggerBody()['text'],' ')
Step-3:
Add another compose data operation, and use the below expression to get the first word of the input string.
first(outputs('Split_the_input_string_values'))
Step-4:
Save and run the flow, and Here, I have passed the input string as Hello World!
Once the flow runs successfully, we can see that it splits the values and returns the first word.
This is how to split the input string value and get the first word in the Power Automate flow
Conclusion
I hope you get an idea of how to get the first word in a string using Power Automate flow,
Additionally, I have also explained how to get the last word in a string and how to split a Split string to get the first word in Power Automate flow.
I have shown you different examples in this tutorial to get the first word and last word in a string by using the first() function, last() function, and split() function in Power Automate flow.
You may also like:
- How to Convert String to Float in Power Automate?
- Convert a String to a Decimal Number in Power Automate
- Convert a String to an Integer in Power Automate
- How to Remove Quotes from String in Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.