How to Check Condition Contains String in Power Automate?

Do you want to check whether a string contains a value in Power Automate? This Power Automate tutorial will help you check whether the string contains a value or not using the contains function in Power Automate.

Scenario:

Recently, I got a requirement to check whether the particular field value contains the string using Power Automate. Here, I will use two SharePoint lists called Inquiry List and Trainer List.

Inquiry List consisting of below fields:

Column NameColumn Type
Namedefault title column
CitySingle line of Text column
ContactNumberNumber column
RemarksMultiple lines of text column
power automate condition contains string

Trainer List consisting of below fields:

Column NameColumn Type
Technologydefault title column
TrainersPeople or Group column
condition contains string in power automate

So, the flow uses an automatic trigger. Whenever a new item is added to the inquiry list, the flow will trigger, and it will check the Remark field contains the string value, if it matches, then it notifies the respective trainer.

  • If the remarks field contains the values PowerApps, PowerAutomate, and PowerBI, then it notifies the PowerPlatform Trainer.
  • Similarly, if the remarks field contains the value SPFX, it notifies the SPFX trainer.
  • Also, if the remarks field contains the value SharePoint, it notifies the SharePoint Trainer.
  • Finally, if the remarks field doesn’t contain any of these values (PowerApps, PowerAutomate, PowerBI, SPFX, SharePoint), it notifies the Others Trainer.

Now we will start to create a flow to check conditions containing string using Power Automate:

Check condition contains string using Power Automate

Let us see how to check whether the condition contains the string value or not using the Power Automate.

Step-1:

Create an automated cloud flow with the trigger when an item is created; provide the required parameters:

  • Site Address: select the SharePoint site address
  • List Name: from the dropdown, select the list name (here, I have selected the Inquiry List)
How to check condition contains string using Power Automate

Step-2:

See also  Power bi measure divide + 9 examples

Add a compose data operation, and from the dynamic content, pass the Remarks field as shown below:

@{triggerOutputs()?['body/Remarks']}
check condition contains string using Power Automate

Step-3:

Add a compose data operation and use the below expression to remove all the white spaces from the remarks field value.

replace(outputs('Remarks'),' ','')
check condition contains string using Power Automate flow

Step-4:

Add a compose data operation and check the remarks field in the SharePoint list containing these values PowerApps, PowerAutomate, and PowerBI.

Here I have also used the tolower()function to check if the remarks field contains lowercase values like power apps, power automate, or power bi.

or(contains(outputs('RemoveWhiteSpaces'),'PowerApps'),contains(outputs('RemoveWhiteSpaces'),toLower('PowerApps')),contains(outputs('RemoveWhiteSpaces'),'PowerAutomate'),contains(outputs('RemoveWhiteSpaces'),toLower('PowerAutomate')),contains(outputs('RemoveWhiteSpaces'),'PowerBI'),contains(outputs('RemoveWhiteSpaces'),toLower('PowerBI')))
Power Automate Contains Function

Add a new step, select compose data operation, and use the below expression to check if the remarks field in the list contains the value SPFX,

contains(outputs('RemoveWhiteSpaces'),'SPFX')
Contains Function in Power Automate

Similarly, add another compose data operation and use the below expression to check whether the remarks field contains the value SharePoint or not.

or(contains(outputs('RemoveWhiteSpaces'),'SharePoint'),contains(outputs('RemoveWhiteSpaces'),toLower('SharePoint')))
Contains Function in Power Automate flow

Finally, add another compose data operation and use the below expression to check if the remarks field doesn’t contain any of these values (PowerApps, PowerAutomate, PowerBI, SPFX, SharePoint).

and(if(equals(outputs('PowerPlatform'),false), true,false),if(equals(outputs('SPFX'),false),true,false),if(equals(outputs('SharePoint'),false),true,false))
Condition if string contains a specific value in Power Automate

Step-5:

Add a new step, then choose the Get items action and provide the required parameters:

  • Site Address: select the SharePoint site address
  • List Name: from the dropdown, select the list name (here, I have selected the Trainer List)
Condition if string contains a specific value in Power Automate flow

Step-6:

Add a condition control and check if the Technology (default title column)is equal to the Power Platform; it will automatically add the apply to each control loop.

Condition if string contains a specific value in the Power Automate

If yes, add another condition control and check if the outputs of PowerPlatform compose data operation is equal to true. If no, leave it blank

In the If yes part, add a send an email action(V2) to notify the Power Platform trainer. Provide the required parameter:

  • To – From the dynamic content, select Trainers Email
  • Subject – Enter the subject of the mail
  • Body – Enter the body of the mail
See also  Could not find a property named on type 'microsoft.dynamics.crm error in Power Automate

If no, leave it blank.

Condition contains text in Power Automate

Inside the loop, Add a new step, select the condition control, and check if the Technology (default title column) is equal to the SPFX,

Power Automate condition contains value

If yes, add another condition control and check if the outputs of the SPFX compose data operation is equal to true. If no, leave it blank

In the If yes part, add a send an email action(V2) to notify the SPFX trainer. Provide the required parameter:

  • To- From the dynamic content, select Trainers Email
  • Subject – Enter the subject of the mail
  • Body – Enter the body of the mail

If no, leave it blank.

condition contains value or not in Power Automate

Inside the loop, Add a new step, select the condition control, and check if the Technology (default title column) is equal to the SharePoint,

condition contains value or not in Power Automate flow

If yes, add another condition control and check if the outputs of SharePoint compose data operation is equal to true. If no, leave it blank

In the If yes part, add a send an email action(V2) to notify the SharePoint trainer. Provide the required parameter:

  • To- From the dynamic content, select Trainers Email
  • Subject – Enter the subject of the mail
  • Body – Enter the body of the mail

If no, leave it blank.

Condition if field contains any value in Power Automate

Add a new step, select the condition control, and check if the Technology (default title column) is equal to Others,

Condition if field contains any value in Power Automate flow

If yes, add another condition control and check if the outputs of the Others compose data operation is equal to true. If no, leave it blank

In the If yes part, add a send an email action(V2) to notify the SharePoint trainer. Provide the required parameter:

  • To- From the dynamic content, select Trainer Email
  • Subject – Enter the subject of the mail
  • Body – Enter the body of the mail

If no, leave it blank.

How to check Condition if field contains any value in Power Automate flow

Step-6:

Our complete flow looks like the below:

How to check Condition if field contains any value in Power Automate

Save and run the flow by selecting the run flow option:

See also  Microsoft Power BI Card - How to use

Test Case-1

The flow will trigger when a new item is added to the SharePoint inquiry list. Here I have added the highlighted list item below.

The Remarks field contains the value SharePoint.

Condition to check if variable contains any Text using Power Automate

Once the flow runs successfully, the SharePoint Trainer will receive an email like the one below. For testing purposes, I used my account to create the list item, which is why the created by field shows my display name.

Similarly, it works for the remaining conditions that are presented in the flow:

Condition to check if variable contains any Text using Power Automate flow

Test Case-2

Similarly, I have added another item in the SharePoint list; in the Remarks field, we can see it doesn’t contain any of these values (PowerApps, PowerAutomate, PowerBI, SPFX, SharePoint).

Condition contains text using Power Automate

So once the flow runs successfully, the Others Trainer will receive an email like the one below:

Condition contains text using Power Automate flow

This is how to check whether the condition contains the string value or not using Power Automate.

Conclusion

So, I hope you get an idea of how to check whether the condition contains the string value or not using the Power Automate Contains function().

I have shown you an example; whenever a new item is added to the inquiry list, the flow will trigger, and it will check whether the Remark field contains the string value if yes, then it notifies the respective trainer.

You may also like the following tutorials:

>