How to Get First Word in a String using Power Automate?

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.

Power Automate get first word from string

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'],' '))
How to Get First Word in String using Power Automate

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')
Get First Word in String using Power Automate

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.

How to Get First Word in String using Power Automate flow

In Outlook, we also received an email only with the first name of the user display name.

Get First Word in String using Power Automate flow

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 NameColumn Type
EmployeeIDdefault title column
EmployeeNamePeople or Group column
EmployeeDesignationText column
How to Get First Word in String using the 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)
power automate get first word in string

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']
Get First Word from String using Power Automate

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'),' '))
Get First Word from String using Power Automate flow

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')
Get First Word from String in Power Automate flow

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.

Get First Word from String in Power Automate

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.

How to Get First Word in String in the Power Automate flow

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.

Power Automate get last word from string

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'],' '))
How to get last word in string using Power Automate

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.
power automate get last word in string

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.

Get Last Word from String in Power Automate

In Outlook, we also received an email only with the last name of the user display name.

get last word from string in Power Automate flow

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)
How to get last word in string using Power Automate flow

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']
How to get last word in string in Power Automate flow

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'),' '))
How to get last word in string in Power Automate

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')
Get last Word from String using Power Automate

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.)

Get Last Word in String in Power Automate

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.

Get Last Word in String in Power Automate flow

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:

Power Automate Split String Get First

Step-2:

Add a compose data operation to split the input string value; for that, use the below expression.

split(triggerBody()['text'],' ')
How to Split String Get First word in Power Automate

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'))
How to Split String Get First word in Power Automate flow

Step-4:

Save and run the flow, and Here, I have passed the input string as Hello World!

Split String Get First word in Power Automate

Once the flow runs successfully, we can see that it splits the values and returns the first word.

Split String Get First word in Power Automate flow

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:

>