Skip to main content

Notifications

Community site session details

Community site session details

Session Id : MBxZSnWOLmk0zjDn0iCfJw
Power Automate - General Discussion
Answered

condition to check if the field has specific keywords in the value

Like (0) ShareShare
ReportReport
Posted on 9 Feb 2024 18:07:22 by 11

A variable V1 with values set to learning, skills, development and many more key words. When a row is added in to entity, if the  title or else  description, where the description value may be null sometime. If any of the keywords which are present in the variable V1 irrespective of case sensitivity. Want update the column description in entity as true.

  • AkshayJJ2 Profile Picture
    11 on 10 Feb 2024 at 17:10:37
    Re: condition to check if the field has specific keywords in the value

    Hello @SamLed , @Matthy79 

    Thank you so much for your prompt response.

    Both the logic/design worked out.

    Thank you so much for your help!!

    looking forward to great learning.

  • Verified answer
    Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on 10 Feb 2024 at 16:24:36
    Re: condition to check if the field has specific keywords in the value

    Matthy79_0-1707582067117.png

    {"id":"321e053c-7e66-4cdb-83d9-fb1b7547eb0d","brandColor":"#8C3900","connectionReferences":{"shared_sharepointonline":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/shared-sharepointonl-b959cb53-5ecb-4b41-805f-06e7795a0bd2"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Scope_search_for_key_words","operationDefinition":{"type":"Scope","actions":{"Compose_key_words":{"type":"Compose","inputs":["learning","skills","development"],"runAfter":{}},"Compose_sample_text":{"type":"Compose","inputs":"This is a sample text to find key words like learning or so","runAfter":{"Compose_key_words":["Succeeded"]}},"Filter_key_words":{"type":"Query","inputs":{"from":"@outputs('Compose_key_words')","where":"@contains(toLower(outputs('Compose_sample_text')), item())"},"runAfter":{"Compose_sample_text":["Succeeded"]},"description":"toLower(outputs('Compose_sample_text'))"},"Compose_key_word_found":{"type":"Compose","inputs":"@if(equals(length(body('Filter_key_words')), 0), false, true)","runAfter":{"Filter_key_words":["Succeeded"]},"description":"if(equals(length(body('Filter_key_words')), 0), false, true)"}},"runAfter":{}}}

     

    Of course you won't need the first 2 actions because one is the trigger where you receive the text and the other should be a global variable you use in filter array. The last action is just to show if the key word is found or not. Depending on your usecase this could be an update action or a condition or whatever.

  • Verified answer
    SamLed Profile Picture
    2,332 Moderator on 10 Feb 2024 at 12:28:08
    Re: condition to check if the field has specific keywords in the value

    Hi @AkshayJJ2,

     

    Obviously, none can work as your input isn't a keyword, but a string that may contain a keyword.

     

    Try this design:

    SamLed_0-1707567758262.png

     

    Expression: 

    length(intersection(split(toLower(variables('Keywords')), ','),split(toLower(outputs('Input')), ' ')))

     

    This flow splits the input by space to create an array of words, splits keywords variable by coma to create an array of keywords. It makes an intersection of both arrays to create an array of all common items. If resulting array's length is greater than 0, that means both arrays contain one or more common items. 

     

    [Edit] for debugging purpose, you can split the expression. Set this part of the expression in a compose before condition: 

    intersection(split(toLower(variables('Keywords')), ','),split(toLower(outputs('Input')), ' '))

    and this one in condition:

    length(outputs('Compose'))

    That way if it fails, you'll be able to see what intersection returns according to your inputs.

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

  • AkshayJJ2 Profile Picture
    11 on 10 Feb 2024 at 10:00:20
    Re: condition to check if the field has specific keywords in the value

    Hello @Matthy79,

    Could you please elaborate with an example demo?

  • Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on 10 Feb 2024 at 07:05:52
    Re: condition to check if the field has specific keywords in the value

    Loops are critical in Power Automate and should be avoided if possible. For this use case I would suggest to use filter array. You can store your key words in a global variable. That way you can save another action in the trigger flow and you can change the key words any time without deploying.

     

    After filter array (contains(toLower(concat(string1, ‘|’, string2)), item()) you can check the length.

  • Verified answer
    Shaheer Ahmad Profile Picture
    2,194 Super User 2025 Season 1 on 10 Feb 2024 at 05:50:34
    Re: condition to check if the field has specific keywords in the value

    What is the datatype of your variable? Are you storing them in an array or just a coma separated string?

    I agree with @SamLed's approach. But if it isn't working out for you you can also store your tags in an array variable.

    For Example:

    [
     "learning", 
     "skills", 
     "development"
    ]

     Then loop through each index using Do Until Loop (Learn how to apply do Until Loop).

    Use a condition inside the loop and reference the current index and use the contains operator.

    You can apply your logic in the True section of the condition.
    Note: try to use toLower() on both values in the condition for better case handling.

    Let me know if this works for you.

  • AkshayJJ2 Profile Picture
    11 on 10 Feb 2024 at 04:57:01
    Re: condition to check if the field has specific keywords in the value

    Hi @SamLed,

    thank you for the response. I tried both the flow designs, Unfortunately both are not working.

    AkshayJJ2_0-1707540690000.png

    The Data source is data verse and the entity is account. If the account title has any of the keywords mentioned in the variable it must give true value with performance efficiency (trying to avoid for each loop).
    Now in example: my title has learn keyword and the variable has learn keyword, but still it is giving false as result.

  • SamLed Profile Picture
    2,332 Moderator on 09 Feb 2024 at 20:42:33
    Re: condition to check if the field has specific keywords in the value

    Hi @AkshayJJ2,

     

    As I'm not sure about what row/entity source (Excel, SharePoint, Dataverse, ...) you are talking about, just giving you how to check matching  of an input against keywords in a case insensitive way.

     

    First flow design (String contains):

    SamLed_0-1707511329088.png

     

    Condition left operand: toLower(variables('Keywords'))

    Condition right operand: trim(toLower(outputs('Input')))

    Operator: Contains

     

    Note:

    • toLower() simulate case insensitive check
    • This design has a drawback, it will returns true if input string is "skill" and you want to match "Skills" in keywords, if you want exact match, see next design.

    Second flow design (Array contains):

    SamLed_2-1707510602413.png

     

    Condition left operand: if(contains(split(toLower(variables('Keywords')), ','), trim(toLower(outputs('Input')))), true, false)

    Condition right operand: true

    Operator: Is equals to

     

    Note:

    • In this design, don't insert space between separating coma and keywords otherwise input won't match split array item.  
    • In this design "Skill" won't match if keyword is "Skills"

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started
Loading complete