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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / If variable contains '...
Power Automate
Unanswered

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 Super User 2025 Season 2 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 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard