November 17, 2024

Comparisons are an essential part of any platform, and Power Automate has fantastic functions to help us with that. For example, the “greaterOrEquals” function serves a significant role and does what you would imagine. It compares if the first value is greater or equals to the second value.

Usage

It follows a simple pattern.

  1. Integer, Float, or String to compare
  2. Integer, Float, or String for the comparison

Let’s start with a simple example:

greaterOrEquals(100,10)

will return 

true

It also works with float numbers; let’s look at strings. However, they are much more complex to compare, and results may be strange in some areas. For example:

greaterOrEquals('b','a')

returns 

true

It makes sense since we know “t” at “a” comes b “f” re “b”, but so does:

greaterOrEquals('b','.a')

returns

true

So depending on how you look at it, it makes sense it’s wrong. Another example is with a string that contains a number.

greaterOrEquals('b','1')

returns

true

Depending on where you look, numbers come before or after when you sort alphabetically, so in this case, you know that numbers are not considered first. We can continue to find examples, but I think this proves my point. You can use it to understand if something is ordered, being a name is “after” another, but be careful and test your Flow. You may get unexpected results.

Let’s look at an array:

greaterOrEquals(createArray(1,2,3),createArray(4,5))

will return an error:

Unable to process template language expressions in action 'Compose' inputs at line '1' and column '6323': 'The template language function 'greaterOrEquals' expects all of its parameters to be either integer or decimal numbers. Found invalid parameter types: 'Array'.'.

No arrays allowed. Finally, let’s try with boolean values:

greaterOrEquals(true,false)

will return an error

Unable to process template language expressions in action 'Compose_2' inputs at line '1' and column '6323': 'The template language function 'greaterOrEquals' expects all of its parameters to be either integer or decimal numbers. Found invalid parameter types: 'Boolean'.'.

The specification is precise here. Boolean values are not comparable, but it’s nice to try and be sure.

Limitations

Like we’ve seen above, arrays, boolean values, and other objects outside strings, integers, and floats are not allowed. I can’t consider this as a limitation since it doesn’t make sense to compare them, but I wanted to stress it here since, in some cases, we can use variables or “Compose” action, for example, so that these values may exist.

Recommendations:

Here are some things to keep in mind”

Use “debug” compose actions

Since the comparison will return true or false, sometimes it’s tricky to understand how the calculation is done, depending on how complex the expression is. So I recommend using Compose actions to have the values that go “in” the function. This way, if the value doesn’t make sense, you can understand, based on the parameters, why it was calculated that way.

Please don’t use it on strings.

We are comparing if a string is “greater” than the other works, but it’s pretty hard to understand the outcome, as we’ve seen above. So even if the string contains a number, use the [int function] first and then compare. Otherwise, there’s no real reason to compare strings like this.
If you have a good example, I want to know about it. Would you please email me or interact on Twitter?

Don’t nest

There’s no real reason to do it. If you try to nest _ greaterOrEquals_ functions, you’ll receive an error since boolean values are not comparable. So be very careful to avoid breaking Flows.

Sources:

Microsoft’s join Function Reference

Back to the Power Automate Function Reference.

Photo by OpticalNomad 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 →

Leave a Reply

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

Mastodon