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 / If variable contains '...
Power Automate
Suggested Answer

If variable contains 'Option A' OR 'Option B'

(1) ShareShare
ReportReport
Posted on by 20

How can I achieve the following OR statement inside an IF function?

 

 

 

SET NewVar TO $'''Option A'''
IF Contains(NewVar, $'''Option A OR Option B''', False) THEN
Display.ShowMessageDialog.ShowMessage Message: $'''Yes''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False
END

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

    @FlashDota 

     

    Please try the below code:

     

    Deenuji_0-1721146213847.png

     

    Deenuji_1-1721146230359.png

     

     

    Code:

     

    SET NewVar TO $'''Option A'''
    IF (Contains(NewVar, 'Option A', False) OR Contains(NewVar, 'Option B', False)) = True THEN
    Display.ShowMessageDialog.ShowMessage Message: $'''Yes''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False
    END

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Power Automate Desktop Community Champion 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • Suggested answer
    BoredFish Profile Picture
    26 on at
    You could use an 'Or' switch in the IF statement as pointed out by Deenuji.
    Another way to do it is with a Switch instead of If, which allows different actions depending on which Option statement is found.
     
    SWITCH NewVar
        CASE = $'''Option A'''
            # Some activity.
        CASE = $'''Option B'''
            # Some other activity.
        DEFAULT
            # Some alternate activity or none at all.
    END
     
  • Suggested answer
    Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at
    I still suggest using nested if conditions instead of a switch, as this nested if approach is less time-consuming compared to switch case approach.
     
     
    Thanks,
    Deenuji Loganathan 👩‍💻
    Power Automate Desktop Community Champion 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

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 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard