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 / Need to comapare multi...
Power Automate
Unanswered

Need to comapare multiple conditions in the If loop in Power Automate Desktop

(0) ShareShare
ReportReport
Posted on by 4

I need to compare the Name and the status of employee are matching or not using IF loop how to compare multiple conditions in the If loop using "AND" and "OR" Operators

I have the same question (0)
  • PetrosF-MSFT Profile Picture
    on at
  • Community Power Platform Member Profile Picture
    on at

    Hi,

     

    I need to multiple conditions in the If statement.

    I have many files of the same pattern, out of it I do not want to delete certain files starting with specific name followed by number ex. 'ABC-1234'.

    I tried the following, but it is not working. Please help for the solution.

     

     

    Radhika1_0-1632904970474.png

     

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    I would approach this completely differently. 

    set up a temp folder

    get files in folder ABC-1234*
    move files to temp

    get files in folder RES-1564*

    move files to temp

    get files in folder FED-1234*
    move files to temp

    get all files in folder

    delete files

    get all files in temp

    move files back to folder

  • Community Power Platform Member Profile Picture
    on at

    Thanks for your reply and it works.

    I posted this to know whether multiple conditions are possible in a single if statement for my scenario.

     

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Here are some ideas you can try, but the solution I know will work is below the dotted line.

     

    Here: https://docs.microsoft.com/en-us/power-automate/desktop-flows/variable-manipulation

     

    It says you can do this:

    MichaelAnnis_0-1632926486864.png

    I personally don't think this would work, because the operator is built into IF, and it doesn't give an And/Or option.

     

    On the other hand, you can do nested If's to accomplish AND functions:

    • If name is
      • If status is
        • Do something
      • EndIF
    • EndIF

    So in this example, it would only "Do something" If both statements were true.

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

    Solution that will definitely work:

     

    You can use Switch & Case to handle all possibilities of AND/OR Functions, but this gets complicated.  You have to set each If Statement to True (1) or False (0), so that looks like this:

    • If Name is True
      • Set Variable %NameIF% to (1)
    • Else
      • Set Variable %NameIF% to (0)
    • EndIF
    • IF Status is True
      • Set Variable %StatusIF% to (1)
    • Else
      • Set Variable %StatusIF% to (0)
    • EndIF
    • Set Variable %Result% to 'Name%NameIF%,Status%StatusIF%' 

    #I used text other than just numbers in %Result% so it didn't mistake it for a number and turn "01" into "1".

     

    Now that you have the result variable, which is 1 of 4 options, you can use Switch Case to "do something" based on your result:

    • Switch %Result%
      • Case Name0,Status0
        • Do something for 0,0
      • Case Name0,Status1
        • Do something for 0,1
      • Case Name1,Status0
        • Do something for 1,0
      • Case Name1,Status1
        • Do something for 1,1

    Best of luck!

  • PAG Profile Picture
    154 on at

    Here is another approach with OR conditions, using a list and looping items:

    https://power.automate.gallery/LIhE73Pp1sy4 

  • Community Power Platform Member Profile Picture
    on at

    Hello @Anonymous 

     

    You can use multiple conditions in IF statement. 🙂

     

    You would better to check the solution posted by @Anonymous  in the thread below:

    Solved: If condition logic - Power Platform Community (microsoft.com)

     

    Also yet another thread discussing the same issue you should read through:

    How to include the logical AND/OR operators in con... - Power Platform Community (microsoft.com)

     

    Thank you.

  • Highboy Profile Picture
    1,183 Super User 2024 Season 1 on at

    Highboy_0-1633334355239.png

    Highboy_1-1633334436955.png

     

  • Highboy Profile Picture
    1,183 Super User 2024 Season 1 on at

    And/Or is working just fine
    Try This example

    Highboy_3-1633335160295.png

     

    Highboy_4-1633335192040.png

     

  • Community Power Platform Member Profile Picture
    on at

    Hi,

    Thank you for your response!

    Actually the match starts with 'ABC-1234' and after that it contains some text (ABC-1234 ttttccvvfilename.pdf). So, I cannot give Match = ABC-1234, I have to give it like Match does not start with 'ABC-1234'. Any idea how to implement?

     

     

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