June 24, 2025

The “max” function is a powerful tool in Power Automate that helps you find the highest value in a set of numbers.

Although it’s not the most used function, it can be quite valuable, so let’s explore how to use it and some common issues and pitfalls. 

Where to find it?

You can find the function in every action where a formula is supported. For example, let’s look at a “Compose” action:

As you can see, we can auto-complete by using the “tab” key (old UI) or “enter” key (new UI). Let’s look at how to use it.

Usage

The “max” function follows two simple patterns:

  1. Finding the maximum value between individual values, like max(value1, value2, ...)
  2. Finding the maximum value in an array, like max(array)

Let’s start with some basic examples:

Comparing individual values

If you want to find the largest of several specific values, you can list them as separate parameters:

max(10, 5, 25)

This will return 25 since it’s the highest value among the provided numbers.

You can also use variables or dynamic content:

max(variables('FirstNumber'), variables('SecondNumber'), 100)

This compares the values stored in the two variables against the number 100, returning whichever is highest.

Finding maximum in an array

One of the most common uses is finding the maximum value in an array:

max(createArray(10, 5, 25, 12, 8))

This will return 25, just like our first example.

Notice that we’re using the “createArray” function to simulate an array. In real-world scenarios, you’ll often work with arrays from previous actions.

Mixing types

You can mix types as long as they are either floats or integers. For example:

max(createArray(10, 10.3, 25,-3))

This will return 25, just like our first example.

Notice that we’re using, as before, the “createArray” function to simulate an array.

Limitations

There are a few things to be aware of when using the “max” function:

Types

I’ll go into detail in the next section, but please provide only integer or floating numbers only. If you provide anything else the Flow will fail. 

Expression size limits

As with all Power Automate expressions, there’s a limit of 8,192 characters. If you’re building complex expressions with large arrays, try to break them into smaller, manageable pieces using variables.

Common Mistakes

Here are some common mistakes to avoid when using the “max” function:

Empty arrays

If you provide an empty array to the “max” function, it will return an error:

max(variables('ARRAY_VARIABLE'))

Here’s a sample exception:

Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'max' expects either an array of numbers or a comma separated list of numbers as its parameters. The function was invoked with no parameters. Please see https://aka.ms/logicexpressions#max for usage details.'.

Basically the variable was empty so the max could not evaluate anything.

Non-numeric values

The “max” function expects numeric values. If you try to use it with strings that cannot be converted to numbers, you’ll get unexpected results or errors:

max('apple', 'banana')

This will result in an error since these strings cannot be converted to numbers.

Here’s an example of the exception.

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

This also happens in case the values in the expression are valid integers but in string format, like this:

max('10', '5')

We’ll get the same exception, so if you suspect this will be the case, you can always use the “int” function to convert them beforehand.

Mixing types

Be careful when comparing different data types. Power Automate won’t try to convert the types and will return an error:

max(100, '50', true)

The exception is helpful because it will return the list of invalid types that exist in the function, in this case, strings and booleans.


InvalidTemplate
Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'max' expects all of its parameters to be either integer or decimal numbers. Found invalid parameter types: 'String,Boolean'.'.

Be careful with this.

Null or undefined values

If your array contains null or undefined values, Power Automate will return an error:

max(createArray(10, null, 20))

Here’s the exception that we get:

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

Notice that null is a type. If you want more details about these special types I have an article explaining them in detail.

Recommendations

Here are some things to keep in mind when using the “max” function:

Use “debug” compose actions

When working with complex data structures, it can be difficult to understand why you’re not getting the expected results. I recommend using “Compose” actions to inspect your arrays and values before passing them to the “max” function.

Always add a comment

Adding a comment will help avoid mistakes and make your Flow easier to maintain. Indicate what you’re trying to find the maximum of and why it’s important. It may seem obvious now, but it might not be in a few months or years. Comments are essential for faster debugging when something goes wrong.

Sources

Microsoft’s max Function Reference

Back to the Power Automate Function Reference.

Photo by Kier in Sight Archives on Unsplash

 

Manuel

I have 20 years of experience in automation, project management, and development. For the past 6 years, I have been writing for this website, sharing (what I think are) valuable insights and information with readers. I strive to use my expertise to create compelling and informative content that resonates with you and, hopefuly saves you time.

View all posts by Manuel →

Leave a Reply

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

Mastodon