Nested If Statements in Power Automate Desktop
    • Dark
      Light
    • PDF

    Nested If Statements in Power Automate Desktop

    • Dark
      Light
    • PDF

    Article Summary

    One challenge that is involved in low code solutions is the real estate that is required to implement the necessary business logic. One scenario is multiple If statements or nested if statements. If you need to check on two (or more) different values, it may take up a lot of real estate.

    In the following image we are going to set two variables and then we want to check to see if Amount is equal to 100 and State is equal to AZ. We can model this as an If statement nested within another If statement. Not only is this more difficult to read, but it also requires us to add multiple Else statements to handle the exception cases.
    1(6)

    Alternatively, we can create an expression that will check to see if Amount is equal to 100 and State is equal to AZ. The way to do this is in an If action is to set the first operand to %Amount = 100 AND State = 'AZ'%. We need to ensure that our statement is embedded withing % % and we can use an operator of AND to join our two statements together. Then what we will do is set our operator to equals and our second operand to true.

    The idea behind this approach is to ensure our First operand statement holds true and if it does, we can then return an output of true. If our First operand statement is not satisfied, our output will be false. In addition, we can expand this statement to include additional conditions, we aren’t just bound to 2.
    2(6)

    Note: In WinAutomation we had operators of && to represent an AND statement. In Power Automate Desktop, we will use the word Else statements to handle the exception cases. instead.

    Visually we can represent this logic as described in the following image.
    3(7)

    Conclusion

    In this post we discussed an approach that can be used to nest If statements, without the need to clutter our design surface. Not only is this easier to read, but also reduces the complexity in manage our else statements and make our config less complex to maintain.


    Was this article helpful?