cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
acolyter
Helper II
Helper II

Condition if string (name) contains a certain letters

Hi,

 

How do I create a condition that allows me to check if a string contains a specific 'name'? What I want is to have a condition that checks if there's a certain 3 letter identifier included in a string that's in a sharepoint list column.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Microsoft
Microsoft

Hi @acolyter 

 

If(Equals(indexOf('This is a string of text','String'),-1),'NO STRING FOUND','WE HAVE A MATCH!')
VS
If(Equals(indexOf('This is text','String'),-1),'NO STRING FOUND','WE HAVE A MATCH!')
 
DamoBird365_0-1637347344895.png
 
-1 is returned by index of if there is no string found.
 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

View solution in original post

5 REPLIES 5
DamoBird365
Microsoft
Microsoft

Hi @acolyter 

 

If(Equals(indexOf('This is a string of text','String'),-1),'NO STRING FOUND','WE HAVE A MATCH!')
VS
If(Equals(indexOf('This is text','String'),-1),'NO STRING FOUND','WE HAVE A MATCH!')
 
DamoBird365_0-1637347344895.png
 
-1 is returned by index of if there is no string found.
 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

ScottShearer
Super User
Super User

@acolyter 

I noticed that you posted this same question in the Using Power Automate forum.  Please post your questions only once in a single forum.  Posting in multiple places causes multiple people to spend time generating a solution for you.  There are solutions posted to your post in the Using Flows forum as well.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Hi Damobird,

 

I have a question. In your logic, you have made a if statemtent which goes like:

If notfound, skip, dothis

How can i change it to work like If found, dothis, skip?

 

Thanks for your help!

Hi @don77 

 

Try not().

 

Damien

Hello @DamoBird365 thanks for this info. is it possible to nest this formula?  I have 5 star ratings which appear in email text (the body field) and have tried various options, this formula is accepted, but the flow fails: if(equals(indexof(triggerBody()?['Body'],'5-star'),-1,if(equals(indexof(triggerBody()?['Body'],'4-star'),-1,if(equals(indexof(triggerBody()?['Body'],'3-star'),-1,if(equals(indexof(triggerBody()?['Body'],'2-star'),-1,if(equals(indexof(triggerBody()?['Body'],'1-star'),-1,'','1')),'2')),'3')),'4')),'5'))

This flags up InvalidTemplate. Unable to process template language expressions in action 'Create_item' inputs at line '0' and column '0': 'The template language function 'if' expects three parameter: the condition to test as the first parameter, the value to return if the condition is true as the second parameter, and the value to return if the condition is false as the third parameter. The function was invoked with '1' parameter(s). Please see https://aka.ms/logicexpressions#if for usage details.'.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

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.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,764)