Power Automate Logical Functions: An Overview

by | Power BI

In this tutorial, we’ll be looking at some Power Automate Logical Functions that we can use in our workflows. We won’t be needing the Condition connector when using these functions.

Power Automate logical functions compare values and expressions which either return true or false in our flows.

We can also get more familiar with the use of Logical Functions by looking at its documentation first. To check, go to Power Automate Documentation. Click the Reference option. Then, click the Workflow Definition Language schema topic. Lastly, choose the Functions reference subtopic. It will then display all the available logical comparison functions and each of their corresponding tasks.

Power Automate logical functions

Understanding The IF function In Power Automate

First, we’ll discuss the if function. This is the most common among Power Automate logical functions because it’s similar to the if function in MS Excel or in coding. In MS workflows, this function checks whether an expression is true or false, and based on the result it will return a specified value.  

Power Automate logical functions

By clicking it in the documentation, we’ll see the parameters and other usage-related information about the function.

Power Automate logical functions

The first argument of an If statement is an expression. The second one specifies what we want the function to return when the expression is true and when it’s false.

Power Automate logical functions

Using The If Function In A Workflow

For this one, we’ll be using the manually triggered sample flow that I previously created.

Power Automate logical functions

The Condition in this flow is set to check if any of the words in Input 4 contains the word “problem”. If the input from the user meets the condition, the expression becomes true. Hence, the flow will go to the If yes pathway. Otherwise, it’ll go to the If no pathway.

Power Automate logical functions

By using the If statement, we can replace the Condition control in our flow. To do that, let’s drag the Post message 2 action.

Power Automate logical functions

Then place it in between the Post message action and the Condition block.

Power Automate logical functions

Click the Message Text field to display the available options.

Power Automate logical functions

Click Expression. Then click the if function under the Logical functions.

Power Automate logical functions

Again, what we’d like to test is whether Input 4 contains the word “problem”. To do this, we’ll first split Input 4 into an array by clicking the split function under String functions.

Power Automate logical functions

Click Dynamic content then click Input 4. We’ll then see that the contents are added to our statement.

Let’s add a comma (,) followed by a space in between a pair of single quote marks (‘’). The space will serve as the content separator of the array items.

Now, we’ll change the statement into an expression. To do that, let’s put the cursor before the word split. Then click the contains function under the Expression tab.

Power Automate logical functions

Remove the excess closing bracket before the word split.

Power Automate logical functions

Let’s add a comma (,), a space, and type in the word “problem” enclosed in single quotation marks (). Then add a closing bracket ()), another comma (,), and a space after that.

So, if there is an element containing the word “problem”, it’ll return true. If not, it’ll return false. If it returns true, we’d like the message to be “Input 4 contains the word problem”. To do this, let’s type the text “Input 4 contains the word problem” at the end of the statement.

If it returns false, we’d like the message to be just a period (.). To do this, let’s add a comma (,) right after the closing quotation mark of the word ”problem”. Add a space, then type the period (.) enclosed in single quotation marks ().

Power Automate logical functions

After that, click OK.

Power Automate logical functions

We can now delete the initial value of the Message Text field.

Power Automate logical functions

Let’s also delete the Condition block.

Power Automate logical functions

Then click OK.

Lastly, click Save.

Power Automate logical functions

Testing The Flow

Let’s now test the flow and see how it works.

Let’s run this using the same data during our previous run. Then, click Test.

After that, we’ll see the result of our successful flow run.

Power Automate logical functions

Upon checking the general channel in Slack., we’ll see that the message “Input 4 contains the word problem” was displayed successfully.

Power Automate logical functions

Therefore, we’ve successfully replaced a Condition control with an If statement which both work exactly the same.

Power Automate logical functions

Other Power Automate Logical Functions

There are 3 other logical comparison functions we’ll go through which are also heavily used—the and, equals, and or functions.

Power Automate logical functions

1. Power Automate Logical Functions: Equals

Let’s check the equals function

Power Automate logical functions

This function is fairly simple and we’ve already used this in previous tutorials. It evaluates two objects which can either be strings, integers, collections, arrays, or others. If the values of the two objects are equal, it’ll return true; and if they’re not, it’ll return false. An example is provided in the documentation as well.

Power Automate logical functions

2. Power Automate Logical Functions: And

Next is the and function.

Power Automate logical functions

This function can be easily used if we have multiple expressions to evaluate. We just put in multiple expressions and they’ll return true if every single expression is true.

Power Automate logical functions

For example, let’s go and edit our flow.

Power Automate logical functions

Click New step.

Let’s click the Control connector.

Then, click Condition.

We’ll set the condition to “Input 4 is equal to problem”. 

After that, click Add then click Add row.

In the additional row, we’ll set the condition to “Input 4 is equal to issue”.

Whatever we input here won’t work because we need to use the Input 4 variable (a dynamic content) instead of just typing Input 4 as strings. But this is only to show you how it looks, which is similar to using the and function in an expression.

In this example, the flow is going to check if the Input 4 is equal to “problem” and if it’s also equal to “issue”. Hence, if both expressions return true, it’ll go down the If yes pathway.

Power Automate logical functions

3. Power Automate Logical Functions: Or

The last one we’ll look at is the or function.

The or function is very similar to the and function. The big difference is that for this function to return true, only one of the expressions needs to be true.

Power Automate logical functions

For example, let’s go back to our flow. Then, click the And button and choose the Or option.

I’ve already used this in one of my previous flows. Let’s check that out by clicking the back arrow at the top.

Then click OK.

After that, click My flows and click ScratchFlow – Twitter from the list.

Click Edit.

Click the Condition block.

Power Automate logical functions

Then, we’ll see that the or function was used in this previous flow. In this example, it evaluates if the tweet contains the word “issue”, or “problem”. If one of these two conditions is true, it’ll perform the action within the If yes pathway which creates a Trello card. If both are false, it’ll do the action that we set for the If no pathway.

Power Automate logical functions

***** Related Links *****
Collection Functions In Microsoft Power Automate
Microsoft Flow String Functions: Concat And Replace
Power Automate Split Function And Arrays

Conclusion

Logical comparison functions are very similar to the Condition connector in Microsoft Power Automate. However, I still recommend using the Condition connector over Logical comparison functions because it’s much easier to use in flow diagrams.

If you’d like to use the logical functions, that’s totally fine especially if you have a coding background. In addition, most Logical comparison functions can be replicated using Condition control connectors instead of using codes.

But of course, it’s still totally up to you on how you’d configure and run your flow. Just keep in mind that if your goal is to become a certified Power Automate Administrator, you should know these functions as well.

All the best,

Henry

Related Posts