web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Help to extract the fi...
Power Automate
Unanswered

Help to extract the first word of a sentence

(0) ShareShare
ReportReport
Posted on by 66

I would like to extract the first name from a name and surname field. This field is called 'Title' and is being fetched from a SharePoint list. I am using the following guide to help:

https://powerusers.microsoft.com/t5/General-Power-Automate/Return-First-word-in-a-string/td-p/83522

 

However, I am having trouble in extracting the number of characters before the space between the name and surname. Here is what I have tried:

 

vpatel55_0-1631297447974.png

While the flow runs, rather than returning the number of characters between the first name and surname, it simply returns the input expression, including the name itself:

 

vpatel55_1-1631297582175.png

 

Next, I tried typing the formula into the expression area:

 

vpatel55_2-1631297852834.png

 

However this fails with the message: "Unable to process template language expressions in action 'Compose' inputs at line '1' and column '53550': 'The template language function 'indexOf' expects its first parameter to be of type string. The provided value is of type 'Null'.":

 

 

vpatel55_3-1631297929221.png

 

This doesn't make sense because as its clear in the second screenshot, the 'Title' is being retrieved and so cannot be null.

 

Any help would be appreciated. Thanks.

Categories:
I have the same question (0)
  • tom_riha Profile Picture
    10,185 Most Valuable Professional on at

    Hello @vpatel55 ,

    In your situation I think the split(...) expression would be better, just split(...) the title by the ' ' character and take the first item from that split

    split([TitleDynamicContent],' ')[0]
    
    Note: replace [TitleDynamicContent] with the dynamic content; enter the whole split(...) as an expression.

     

  • vpatel55 Profile Picture
    66 on at

    HI @tom_riha thank you for your response. Unfortunately I'm still getting a variation of the same error however, "'The template language function 'split' expects its first parameter to be of type string. The provided value is of type 'Null'. "

     

    However, we can clearly see that 'Title' was not null.

     

    vpatel55_1-1631347673186.png

    Here is the expression that I used:

     

    vpatel55_0-1631347524496.png

     

    I'm not sure if its relevant, but when I start typing the 'split' expression, 'Title' (and almost most other fields) disappear from the dynamic content list. I only achieved the above by manually typing in 'Title'. Perhaps it is not shown because its not available to use, and is returning 'Null' because it can't see it?

     

    This is what I mean, 'Title' is at first available as a dynamic content expression:

    vpatel55_2-1631348094710.png

     

    But when I type in Split, it disappears:

    vpatel55_3-1631348220009.png

     

    Any assistance would be very welcome. Thanks again.

     

  • Verified answer
    tom_riha Profile Picture
    10,185 Most Valuable Professional on at

    Hello @vpatel55 ,

    try to address the title by using outputs(...) instead of body(...).

     

    split(outputs('Get_items')?[Title],' ')[0]

    update:

    since it's using output from 'Get items', it'll always return an array. You should loop through the output and then, inside the apply to each, do the split.

    split(item()?['Title'],' ')[0]

    image.png

     

  • vpatel55 Profile Picture
    66 on at

    Hi @tom_riha thanks, that works! Super user indeed! I will certainly need to see how this works - it was much more complex than I had anticipated. Many thanks and much appreciated.

  • rh2150 Profile Picture
    4 on at

    Hi, maybe this can help in a future somebody struggling with the same situation. You can just create a variable and use this formula:

    first(split('string', 'separator'))

     

    In the most cases when handling names the separator will be an space ' ' and if you add the first function it will give as output the first word in the string.

     

    Hope it helps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard