cancel
Showing results for 
Search instead for 
Did you mean: 

Substring/split/parse a string

It would be nice to have a function that would allow us to split a string based on a character or substring

 

Something like Split("FirstName LastName") and have it return a single record table or something like that

Status: Completed

At this time you have several text functions that might be able to help with this. To see all of them, click the FX between the property and the function bar at the top of the screen. The ones I use the most are Left(), Mid(), and Right() and Trim(). If I wanted to split a text box called "FullNameBox" with the First and Last Name separated by a space, I would use the following two functions:

 

FullNameBox contains: "Audrie Gordon"

First Name: Left(FullNameBox.Text,Find(" ",FullNameBox.Text))

Last Name: Right(FullNameBox.Text,Find(" ",FullNameBox.Text))

 

See also: https://powerapps.microsoft.com/en-us/tutorials/function-left-mid-right/

 

Let me know if this was helpful.

 

Audrie

 

 

Comments
Level 8

Or perhaps a single column table with each record representing 1 substring that the split returned. That way we could do a count on the number of records to see if the split returned the number of results we were expecting.

Power Automate Staff
Status changed to: Completed

At this time you have several text functions that might be able to help with this. To see all of them, click the FX between the property and the function bar at the top of the screen. The ones I use the most are Left(), Mid(), and Right() and Trim(). If I wanted to split a text box called "FullNameBox" with the First and Last Name separated by a space, I would use the following two functions:

 

FullNameBox contains: "Audrie Gordon"

First Name: Left(FullNameBox.Text,Find(" ",FullNameBox.Text))

Last Name: Right(FullNameBox.Text,Find(" ",FullNameBox.Text))

 

See also: https://powerapps.microsoft.com/en-us/tutorials/function-left-mid-right/

 

Let me know if this was helpful.

 

Audrie

 

 

Level: Powered On

What happens when there are more than two names?

Level: Power Up

values directly from office , use this one 


Left(User().FullName,Find(" ",User().FullName))

Level 10

@fsaetre @Audrie-MSFT

For some reason Right did not work when the string had this format: "Mister Middle Name".
Might be that I don't understand the function Right correctly, but the result was this: "iddle Name"
I am not trying to get the middle name, just cut the string at the first " " and keep whats on the right part of that first " ".

 

But Mid on the other hand gave me the correct value: "Middle Name"

MidStringStartingPositionNumberOfCharacters )
RightStringNumberOfCharacters )

If I read it correctly, the starting posistion for Mid would then be: " "
Mid(FullNameBox.Text,Find(" ",FullNameBox.Text))
And the third parameter for Mid is not used.

Power Automate Staff
Level: Powered On

The Right example here only works because the first and last name have the same length. If the last name isis of different length than the first then you need to use (and likely should always use)

Right(FullNameBox.Text,Len(FullNameBox.Text) - Find(" ",FullNameBox.Text))