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 assign multiple...
Power Automate
Unanswered

How to assign multiple values in a single variable with an OR statement.

(0) ShareShare
ReportReport
Posted on by 6

I want to create a variable which stores multiple hard codded values. 

 

If this value exists in an OR statement, it will proceed into the next task.

 

The syntax for hard codded values is %'value'%. So do I write the variable like this?

 

%'value'% OR %'value'% OR %'value'% 

Power Automate Variable Example.PNG
I have the same question (0)
  • UshaJyothiKasibhotla Profile Picture
    225 Moderator on at

    From where you re getting the Value of the variable?

    if you want to check the variable contains the value or noy You need to Use if activity

    then Check with If activity. as shown below.

    UshaJyothi20_0-1707474528099.png

    Please ignore the error sine yourvariable is the variable which you need to check.

    For more clarification please explain your scenario.

     

    Hope this helps,

    Usha.

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @mxdataengineer,

     

    Please find the below attached suggestion from MS for variable manipulation:

    Deenuji_1-1707505616783.png

     

    Link - https://learn.microsoft.com/en-us/power-automate/desktop-flows/variable-manipulation#logical-operators

     


    The sample code tailored to your specific use case entails the following:
    It enters the loop if 'newvar' holds the value '2' or 'value'.

    Deenuji_0-1707505580911.png


    Code:

    SET NewVar TO 2
    IF (NewVar = 'value' OR NewVar = 2) = $'''True''' THEN
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Deenu\\Accounts_Details_one.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    END

     

     

     

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

    Thanks,

    Deenu

  • mxdataengineer Profile Picture
    6 on at

    Hey both, what am I suppose to add if the 'YourVariable' variable does not exists? 

     

    Q - From where you re getting the Value of the variable?

    A - It is a hard coded value I assign myself. 

  • UshaJyothiKasibhotla Profile Picture
    225 Moderator on at

    Hi @mxdataengineer 

    Use set variable activity and assign your value to the variable.

     

    Hope this helps

    Usha

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @mxdataengineer,

    Please adhere to the method outlined by @UshaJyothi20 as mentioned earlier.


    Thanks,

    Deenu

  • mxdataengineer Profile Picture
    6 on at

    Hey there @UshaJyothi20 @Deenuji 

     

    I had created the new Variable and assigned the value similar to 'YourVariable' earlier (since new Variables created cannot be blank). The flows runs but it doesn't complete the task as intended. 

     

    In the If activity, I set First Operand as %NewVar% (assigning the new variable itself). 

     

    Power Automate Variable Example 13022024.PNG
  • cwischnewski Profile Picture
    162 on at

    Screenshot 2024-02-13 082708.pngScreenshot 2024-02-13 082822.pngIt isn't clear what you are wanting to do.  Someone above provided a great link to use.  The percent notation gives you the ability to do a lot.  A variable only ever has one value, but the conditional If can use percent notation to build a complex criteria inside of percent signs.  If you had two variable that might have various values throughout the flow and you want to see if either contains some string, for instance, build that out.

     

     

    SET MyFirstVariable TO $'''%''%'''
    SET MySecondVariable TO $'''This value has something'''
    IF (IsEmpty(MyFirstVariable) OR Contains(MySecondVariable, MyFirstVariable, True)) = True THEN
    SET MySecondVariable TO $'''%MySecondVariable%
    And then some more.'''
    END

     

    This block will set the two variables, then check if the first one is empty it will do that block, but if it isn't, it will check if the second variable contains the first.  One thing to note is that %True% is the boolean value.

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @mxdataengineer   It seems you haven't add any value in the If condition. Please find the below reference flow for your use case.

    Flow:

    Deenuji_2-1707836941342.png

     

    Code:

    Outlook.Launch Instance=> OutlookInstance
    SET NewVar TO $'''Deenu@gmail.com'''
    IF NewVar = $'''Deenu@gmail.com''' THEN
    Outlook.RetrieveEmailMessages.RetrieveEmails Instance: OutlookInstance Account: $'''Deenu@gmail.com''' MailFolder: $'''Inbox''' EmailsToRetrieve: Outlook.RetrieveMessagesMode.Unread MarkAsRead: True ReadBodyAsHtml: False Messages=> RetrievedEmails
    END



    Hope this helps. Else please share your exact use case, I will try to help you more accurate.

    Thanks,

    Deenu

  • mxdataengineer Profile Picture
    6 on at

    Hey all, 

     

    I made some progress today as I got the flow to work (successful) earlier using the If and Input Variables, 

     

    For some reason the additional variable I added show otherwise, the entire flow run but it did not complete the task as intended. Could you please suggest how I could get this flow to run? 

    Main - Added 2 new variables with the same variable name NewVar, assigned 2 Input variable to NewVar 
    Example - The If statement is to determine if NewVar contains the assigned value NewInput and NewInput2 
    Subject Contains - NewVar only. If NewVar is True, the flow will continue to run. 

    Power Automate Variable Example 14022024.PNG
    Power Automate Variable Subject Contains 14022024.PNG
    Power Automate Variable Main 14022024.PNG
  • cwischnewski Profile Picture
    162 on at

    You don't seem to understand how variables work.  A variable only ever has a single value.  When you assign NewVar in step 2 to NewInput, that is what NewVar is.  Then when you assign NewVar in step 3 to NewInput2, that is now the value, it is no longer equal to NewInput unless that just happens to be the same.

     

    You have 5 total variables in this flow.  NewInput and NewInput2 get assigned initially by the default or calling process.  But they are variables and you can check their value in a condition and assign them new values throughout the flow.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 252 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 169

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard