web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get Max value from an ...
Power Automate
Answered

Get Max value from an array

(0) ShareShare
ReportReport
Posted on by 12

Hi Community,

 

Please advice me on the following. For a flow I'm trying to get the max value for a selection of rows.

The data in excel is as follows.

ItemVendorPrice
ABC1231,5
ABC4565
DEF1232

 

I'm trying to achieve 2 things:
For an item get the Maximum price and the Average price.

The average price I've solved but i'm struggeling with the maximum price.
So first I am getting all the results in my data set filtering on the item.

Koense_0-1665041074545.png

Then I'm selecting the prices column.

The output of the select is as follows:

[
  "3",
  "11"
]
 
To get the average my flow reads as follows (If any suggestions for optimalisation please feel free to add).
Koense_1-1665041553418.png

 

 Now this gets me the average price. 

 If I try a similar expression for the max it fails.
max(outputs('List_rows_present_in_a_table')?['body'])
I assume this is because the values of the array are non decimal. 
Koense_2-1665041875000.png

 

That makes sense I am however struggeling to correct this. 
Using the XML output (as I do for the average) also results in an error.

 

Please advice on how the get the maximum purchase price. 
Thanks in advance,

Koen

Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,828 Most Valuable Professional on at

    Hi @Koense,

     

    For the Maximum price, I would use a float with a local in your Select. After that you should be able to use the max function on the body of the Select.

     

    Try something like below.

     

    Map field in text mode

     

    float(item()?['Price'], 'nl-nl')

     

     

    Expression in Compose action

     

    max(body('Select'))

     

     

    float_locale.png

  • Koense Profile Picture
    12 on at

    Hi Expiscornovus,

    Thanks a lot for the suggestion. I do however run into problems with the float.
    The output for value is similar to this: 

    {
    "@odata.etag": "",
    "ItemInternalId": "aadc12ca-99cc-4156-bd89-89fd39ccc000",
    "Product": "S6050",
    "Price": "3",
    },
    {
    "@odata.etag": "",
    "ItemInternalId": "a87e462a-1c88-487b-bf2d-3d2243c90c6d",
    "Product": "S6050",
    "Price": "11",
    }

     
    When trying to add "Price" as dynamic content to the float it doesn't show up as an option (just body & value).
    When using body/value it returns invalid:

    InvalidTemplate. The execution of template action 'Select' failed: The evaluation of 'query' action 'where' expression '@float(outputs('List_rows_present_in_a_table')?['body/value'])' failed: 'The template language function 'float' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.
     
    When trying to point directly to the price column
     float(outputs('List_rows_present_in_a_table')?['body/value']?['Price]) 
    it also fails: 
    InvalidTemplate. The execution of template action 'Select' failed: The evaluation of 'query' action 'where' expression '@float(outputs('List_rows_present_in_a_table')?['body/value']?['Price'])' failed: 'The template language expression 'float(outputs('List_rows_present_in_a_table')?['body/value']?['Price'])' cannot be evaluated because property 'Price' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.

    Please advice.
  • Verified answer
    Expiscornovus Profile Picture
    33,828 Most Valuable Professional on at

    Hi @Koense

     

    Within a Select Map field you cannot refer to the whole array. You can use the item()?['NameOfField'] syntax instead.

     

    Did you try the expression I suggested earlier?

    float(item()?['Price'], 'nl-nl')

     

  • Koense Profile Picture
    12 on at

    Thanks @Expiscornovus ,
    I should think less and listen more 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 557

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 264 Super User 2026 Season 1

Last 30 days Overall leaderboard