Condition Vs Expressions In Power Automate

Introduction

In power automate you will often find yourself using logic to determine an output for example if a value is true you want to send an email false you don’t want to send a email.

What is the difference?

Condition

  • A Condition is a predefined action that evaluates a specific statement or value to determine if it’s true or false.
  • It’s often represented visually in Power Automate as a logic block with two outcomes: “If Yes” or “If No.” You can add actions based on those outcomes.
  • Example: “If the variable = TRUE send a Email.”
  • Can take longer to run automation

Expression

  • An Expression is a more flexible, code-based approach that allows you to write logic using functions and outputs. Expressions use the Power Automate language and allow for complex calculations or evaluations.
  • Example: length(triggerBody()?['fullname']) > 100 checks if users full name length is greater than 100 characters.
  • Quicker at running within automation

Condition

Conditions are very simple to set up and in most cases require no code, just pure logic. 

For this example we are going to look at employee table and do the following based on the outputs from the SharePoint List:

  • Work location = “Hybrid” and Has Car = False, Car Needed = TRUE
  • Work location = “Hybrid” and Has Car = True, Car Needed = False
  • Work location = “Remote” and Has Car = False, Car Needed = False
  • Work location = “Remote” and Has Car = true, Car Needed = False
  • Work location = “Office” and Has Car = False, Car Needed = True
  • Work location = “Office” and Has Car = true, Car Needed = False
This doesn’t seem very complex but when using conditions this can soon start to build out making it very complicated and the more conditions we add the slower the flow will run. Also what happens if we wanted to update multiple different fields which could all be different based on different values?
 

 Building a condition this way requires alot of condition actions and is not easily changed making it confusing and harder to add actions later down the line.

Expressions

At first expressions can be a bit more difficult to set up, there is a slight learning curve to understand how expressions work and what logic can be applied. 

If we use the same logic as we did for the condition:

  • Work location = “Hybrid” and Has Car = False, Car Needed = TRUE
  • Work location = “Hybrid” and Has Car = True, Car Needed = False
  • Work location = “Remote” and Has Car = False, Car Needed = False
  • Work location = “Remote” and Has Car = true, Car Needed = False
  • Work location = “Office” and Has Car = False, Car Needed = True
  • Work location = “Office” and Has Car = true, Car Needed = False
We can use the below logic in the ‘Need Car’ field

 

				
					if(
    and(equals(items('For_each')?['WorkLocation/Value'], 'Hybrid'), equals(items('For_each')?['HasCar_x003f_'], false)),
    true,
    if(
        and(equals(items('For_each')?['WorkLocation/Value'], 'Hybrid'), equals(items('For_each')?['HasCar_x003f_'], true)),
        false,
        if(
            and(equals(items('For_each')?['WorkLocation/Value'], 'Remote'), equals(items('For_each')?['HasCar_x003f_'], false)),
            false,
            if(
                and(equals(items('For_each')?['WorkLocation/Value'], 'Remote'), equals(items('For_each')?['HasCar_x003f_'], true)),
                false,
                if(
                    and(equals(items('For_each')?['WorkLocation/Value'], 'Office'), equals(items('For_each')?['HasCar_x003f_'], false)),
                    true,
                    if(
                        and(equals(items('For_each')?['WorkLocation/Value'], 'Office'), equals(items('For_each')?['HasCar_x003f_'], true)),
                        false,
                        null
                    )
                )
            )
        )
    )
)

				
			

As you can see from the screenshot below this has been greatly simplified by using an expression only 1 action is required which is the ‘Update item’ and the expression can go directly in a column level allowing multiple columns to be updated depending on certain logic

Outcome

In the two scenarios above we ran both automations, the first one using the conditions took 7 seconds to run updating 14 records

When we did the test using the expression the flow ran in 4 seconds making it alot quicker to update

Although there doesn’t seem to be a lot of difference between the two times, 3 seconds is a lot of difference per action, your scenario might just be a simple flow but over time as more actions get added and you loop through more records this can gradually slow down your flow and thus taking longer for end users to receive that information, this is especially important when using flows inside Canvas Apps.

Conditions are very useful and come in handy in all sorts of scenarios however to handle more complex logic and multiple updates to certain fields expressions makes it a lot easier. Also when dealing with blank data formulas is easier to handle in most cases

Like this post? Why not share it!

LinkedIn
WhatsApp
Facebook
Reddit
X
Email

View more blog posts

Creating A Dataverse Table

11 min read

Read this blog

Dataverse Lookup In Power Automate

2 min read

Read this blog

Getting Workflow Details From A Power Automate Flow

2 min read

Read this blog

Attach File(s) to email With Power Automate

3 min read

Read this blog

Get In Touch

Let’s talk. Send us a message, and we’ll help you explore the best Power Platform solution for your business

We can turn your mondain tasks into effective workflows, saving you and your business time and money