cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Erase second surname using PA

Hey!

 

I'm trying to build the following flow:

 

Input: WORKS

JSON: WORKS

  • NAME: frontname Surname - Surname
  • ADRESS: adress
  • ETC.

Output NAME: Frontname Surname: DOESN'T WORK, HELP!

ADRESS: WORKS

i.e.

NAME: Katniss Mellark - Everdeen --> Kattnis Mellark

Adress: District 12

NAME: Peeta Mellark --> Peeta Mellark

Adress: District 12

So I'd like the second surname to disappear. 

 

Can anyone help me out on how to do this please? I think I have to use if/else functions... but I don't know for sure...

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
tom_riha
Super User
Super User

Hello @Anonymous ,

if the second name is always after a - you can use the split(...) expression, split the string by the - and take only the first part, e.g.

split('Katniss Mellark - Everdeen', '-')[0]

and combine it with the trim(...) to remove the potential empty spaces

trim(split('Katniss Mellark - Everdeen', '-')[0])


[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

1 REPLY 1
tom_riha
Super User
Super User

Hello @Anonymous ,

if the second name is always after a - you can use the split(...) expression, split the string by the - and take only the first part, e.g.

split('Katniss Mellark - Everdeen', '-')[0]

and combine it with the trim(...) to remove the potential empty spaces

trim(split('Katniss Mellark - Everdeen', '-')[0])


[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (5,182)