July 21, 2024

Nothing compares to the Power Automate “if “function when it comes to fundamental functions. It exists in all platforms, programming languages, and tools. You name it, and if it allows some customization, it contains a Power Automate “if “function.

So let’s look at the if function for Power Automate.


It follows a simple pattern.

  1. Expression to check
  2. The value/expression if the result is “true.”
  3. The value/expression if the result is “false.”
The “expression to check” in the Power Automate “if“ function usually requires other functions to work. Any function that returns a true/false result is useful in this case.

Let’s start with a simple example:

if(equals(1,2),'equal','not equal')

will return 

not equal

It’s a silly example, but let’s look at the expression from the “Add Attachments to Planner from Teams” template:


We’re using the lessOrEquals function to check if a string is less than 255. If it is, we return the string; otherwise, we do some operations to it. The point is that you can lest many actions, and that’s fine. But keep things as readable as possible.

Finally, it’s essential to understand that the string “true” is not a boolean. Be especially careful with these cases because if the function will return an error:

Unable to process template language expressions in action 'Compose' inputs at line '1' and column '6311': 'The template language function 'if' expects its first parameter to be of type boolean. The provided value is of type 'String.' Please see https://aka.ms/logicexpressions#if for usage details.'.


It’s not quite a limitation, but you can only have, in the expression, boolean values. Any variation, like “True” or one, will not be accepted, and Power Automate will return an error. Also, be careful with the nesting level. I’ve tried with 30, and all worked fine, but you should simplify the expression if you have something over 30 levels before continuing. Finally, remember that you have the Switch Action that could be a valid alternative if you’re comparing values.


Here are some things to keep in mind.

If you don’t have an expression, you probably don’t need it.

If you don’t have an expression in the first parameter, you probably don’t need the Power Automate “if “function. Why? Because if you don’t have an expression, the result will always be the same. So if it’s always the same, you don’t need it. For example:

if(true,'All good','Will never use this option')

There’s only one exception where you have a variable in the first parameter. That variable can contain true or false, but if it’s the case, don’t forget to add a note explaining why you’re using a variable.

Minimize nesting

It’s possible to nest, and it’s even recommended in some cases. But keep nesting to a minimum since the more layers you have, the harder it is to debug. Also, avoid nesting the expression—same reason as above. Analyzing an expression with many nested layers will be hard when something goes wrong.


Microsoft’s if Function Reference

Back to the Power Automate Function Reference.

Photo by Jac Alexandru on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

2 thoughts on “Power Automate: if function

  1. Great stuff! But… How would you evaluate a boolean (true vs false) then? Should the value be converted into an integer first?

Leave a Reply to Shaun Cancel reply

Your email address will not be published. Required fields are marked *