Skip to main content

Notifications

Power Automate - General Discussion
Answered

IndexOf inside a SubString

(1) ShareShare
ReportReport
Posted on by

Hi,

I'm trying to get the First Name of a contact from a field by finding the first ' ' in their full name

Any idea why this formula including add() works:

 

 

 

 

substring(triggerBody()?['05 - CS Contact'],1,add(indexOf(triggerBody()?['05 - CS Contact'],' ') ,-1 ) )

 

 

 

 

 

But this without add() gives a 'The expression is invalid' message:

 

 

 

 

substring(triggerBody()?['05 - CS Contact'],1, indexOf(triggerBody()?['05 - CS Contact'],' ') -1 )

 

 

 

 

 

OllyH_0-1712753671344.png

 

Cheers!

 

 

 

 

  • ScottShearer Profile Picture
    ScottShearer 25,150 on at
    Re: IndexOf inside a SubString

    @OllyH 

    Using a couple of split()  expressions will work also

    image.pngimage.png

  • OllyH Profile Picture
    OllyH on at
    Re: IndexOf inside a SubString

    Done! 😁

  • Re: IndexOf inside a SubString

    Hi @OllyH ,

    If I solved your problem, could you please mark my reply as the solution? This way I will help more people in the future.😃

    Best Regards,

    Sunshine Gu

  • Verified answer
    Re: IndexOf inside a SubString

    Hi @OllyH ,

    Because if there is no function outside ‘-1’, it will be defaulted to a string, which does not meet the requirements of the formula.

    If you add the 'add' function, the index position of the first space represented by the space is subtracted by 1.

    Best Regards,

    Sunshine Gu

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,526

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard