web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to Compare strings...
Power Automate
Unanswered

How to Compare strings in IF condition in power automate desktop

(0) ShareShare
ReportReport
Posted on by 9

Sivapriya_0-1708102638935.png

I am trying to compare the variable containing string value with a static text using the expression mentioned in the screenshot but it is throwing error. Could anyone help on how to compare strings in if condition?

 

I have the same question (0)
  • Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at

    @Sivapriya  - Hope you are doing well.

    We can achieve those two different ways. Please refer the below reference and code:

    Deenuji_0-1708109646443.png

    Method1 If condition:

    Deenuji_1-1708109761954.png

    Method2 If condition:

    Deenuji_2-1708109819994.png

     

     

    Code:

    SET CompanyData TO $'''AMA'''
    # #Method1
    IF Contains(CompanyData, $'''AMA''', False) THEN
    Display.ShowMessageDialog.ShowMessage Title: $'''tes''' Message: $'''true''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
    END
    # #Method2
    IF (Contains(CompanyData, $'''AMA''', False)) = $'''TRUE''' THEN
    Display.ShowMessageDialog.ShowMessage Title: $'''tes''' Message: $'''true''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
    END

     

    Thanks,

    Deenu

    ------------------------------------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up. Thank you.

  • Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at

    Hi @Sivapriya,

    Any updates? Did you tried the above suggested workaround?

     

    Thanks,

    Deenu

    ------------------------------------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up. Thank you.

     
  • Sivapriya Profile Picture
    9 on at

    Sivapriya_0-1708494394285.png

    First of all, I dont see first operand, second operand and operator options in my IF condition. i tried the code you had mentioned but that also din work. I am getting error "Expression must contain a boolean value"

  • Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at

    @Sivapriya 

    Hope you are doing well!!

     

    If I grasp your concerns accurately, it seems that you created your flow by activating "Power Fx", which is why the operand isn't displaying in the if condition.

     

    Thus, kindly recreate a new flow by deactivating the Power Fx option and then copy and paste the above mentioned code. This should resolve the issue.

     

    Deenuji_0-1708496483502.png

     

    Best regards,

    Deenuji Loganathan
    Follow me on LinkedIn - Deenuji Loganathan 

     

    If I've successfully resolved your queries, please consider accepting this as the solution and giving it a thumbs up. Your feedback is greatly appreciated!

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If you want to continue using Power Fx in your flow, the correct way to do a condition like that is as follows:

    Agnius_0-1708779110299.png

     

     

    You need to use the 'in' operator to check if a substring is present in a string. If the substring or the string is a literal value and not a variable, you need to encapsulate it in double quotes.

     

    Please note, that 'in' is case insensitive (it will ignore the case of the strings). If you want a case-sensitive check, use 'exactin' instead.

     

    See the following article for reference on the logical operators available in Power Fx: https://learn.microsoft.com/en-us/power-platform/power-fx/operators 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard