Skip to main content

Notifications

Power Automate - Power Automate Desktop
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

  • Suggested answer
    Deenuji_Loganathan_ Profile Picture
    Deenuji_Loganathan_ 6,087 on at
    If variable contains 'Option A' OR 'Option B'
    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 🚀
  • Suggested answer
    BoredFish Profile Picture
    BoredFish 23 on at
    If variable contains 'Option A' OR 'Option B'
    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
     
  • Deenuji_Loganathan_ Profile Picture
    Deenuji_Loganathan_ 6,087 on at
    Re: If variable contains 'Option A' OR 'Option B'

    @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 🚀

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,691

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 65,019

Leaderboard