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 / IndexOf inside a SubSt...
Power Automate
Unanswered

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!

 

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    v-yetonggu-msft Profile Picture
    on at

    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

  • v-yetonggu-msft Profile Picture
    on at

    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

  • OllyH Profile Picture
    on at

    Done! 😁

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @OllyH 

    Using a couple of split()  expressions will work also

    image.pngimage.png

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