November 20, 2024

The min Function finds in an array of numbers the lowest number. Quite simple and handy.

Usage

It follows a simple pattern.

  1. An array of numbers (integer or float)

Example:

Array called 'NUMBERS' with the following elements:
[2,4,3,1,6,8,9,10,1,22,214,55,3,2,1]

min(variables('NUMBERS'))

will return 

1

Quite straightforward, right?

How about float numbers?

Array called 'NUMBERS' with the following elements:
[2,4.2,3,0.2,1,6,8,9,10,1,22,214,55,3,2,1]

min(variables('NUMBERS'))

will return 

0.2

Works perfectly even if you mix them in the same array.

If you want to create the array directly in the function you can do the following:

min(createArray(1,2,3))

and it will return 

1

Limitations

There are no documented limitations. I tried to do a min on an array with 200K numbers and it didn’t seem to delay the Power Automate’s execution time, so I think you should be ok on your day-to-day arrays.

Recommendations:

  1. Don’t create the array inside the function. Always use variables to make the Power Automate more readable and separate the responsibilities.
  2. Use a Compose with the function. I know that this is wasteful, but you can see if the value returned is the one you’re expecting and not another value. If you perform it inside a formula you may have difficulty debuting it, since you’re never sure of the value that comes out of the min.
  3. Don’t nest it. There’s no real reason to do it but if you find yourself in a situation where you have nested min functions in a formula, you should review it and make everything more straightforward.

Sources:

Microsoft’s min Function Reference

 

Back to the Power Automate Function Reference.

Photo by Uriel Soberanes 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