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 / How to retreive or cal...
Power Automate
Answered

How to retreive or calculate minimum and maximum values from data after parse JSON

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am bulding a flow which retrieves a .json. (http action GET)
This .json contains 24 items. 
One of the values in these 24 items is the temperature data from a wheaterstation.
With the Parse Json I am able to convert the data to html, csv or use select from the Data Operations actions.
As an example the result from the select action in my flow:


json to select.png

 

From the 24 temperature values I want to determine the minimum and maximum temperature (and write them to a Sharepoint list). I have tried several suggested solutions to retrieve the minimum and maximum value, however did not succeed in finding a working solution. Perhaps I am looking for the wrong solutions, search terms etc.

 
What have i tried :

https://powerusers.microsoft.com/t5/Building-Flows/Convert-array-to-string/td-p/79125

 

https://powerusers.microsoft.com/t5/Building-Flows/How-to-get-value-of-array-from-a-JSON-Object-using-Apply-To-Each/m-p/79788#M7947

 

https://powerusers.microsoft.com/t5/Building-Flows/How-to-access-JSON-Array-items/td-p/83265

 

Resulting in errors as non supported types (float or string) etc. 

 

Maybe one of you could point me in the right direction?

 

 

 

Categories:
I have the same question (0)
  • PieterVeenstra Profile Picture
    on at

    The easiest way is probably just to use actions that set variables within an Apply to Each step.

     

    So within the Apply to each use a condition to thet the loweest value, the highest value to keep the total and keep a counter.

     

    Then after the Apply to each calculate the average.

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    Could you please share a full screenshot of your flow's configuration?

     

    I agree with @Pieter_Veenstra's thought almost, I have made a test on my side and please take a try with the following workaround:

    • Add a proper trigger, here I use Flow Button trigger.
    • Add a Compose action, Inputs set to following json data that you mentioned:
    [
     {
     "time": "2018-04-04T00:00:00",
     "temperature": 8.7,
     "relativeHumidity": 98,
     "rainPastHour": 5.3
     },
     {
     "time": "2018-04-05T00:00:00",
     "temperature": 8.8,
     "relativeHumidity": 98,
     "rainPastHour": 5.3
     },
     {
     "time": "2018-04-06T00:00:00",
     "temperature": 12,
     "relativeHumidity": 98,
     "rainPastHour": 5.3
     },
     {
     "time": "2018-04-07T00:00:00",
     "temperature": 10,
     "relativeHumidity": 98,
     "rainPastHour": 5.3
     },
     {
     "time": "2018-04-08T00:00:00",
     "temperature": 6.1,
     "relativeHumidity": 98,
     "rainPastHour": 5.3
     }
    ]
    • Add a "Select" action, From set to output of "Compose" action. Within Map entry, type one entry. Name set to Temp and Value set to following formula:
    item()?['temperature']
    • Add a Variables-> "Initialize variable" action, Name set to MaximunValue, Type set to Float and Value set to following formula:
    first(body('Select'))?['Temp']
    • Add a Variables-> "Initialize variable" action, Name set to MinimumValue, Type set to Float and Value set to following formula:
    first(body('Select'))?['Temp']
    • Add a parallel branch action, within left branch, add a "Apply to each" action, Input parameter set to output of "Select" action. Wihtin "Apply to each" action, add a Condition, Click "Edit in advanced mode", type the following formula:
    @greater(item()?['Temp'], variables('MaximunValue'))

    Within "If/yes" branch of Condition, add a "Set variable" action, Name set to MaximunValue, Value set to following formula:

    item()?['Temp']

    Within right branch, add a "Apply to each 2" action, Input parameter set to output of "Select" action. Wihtin "Apply to each" action, add a Condition, Click "Edit in advanced mode", type the following formula:

    @less(item()?['Temp'], variables('MinimumValue'))

    Within "If/yes" branch of Condition, add a "Set variable" action, Name set to MinimumValue, Value set to following formula:

    item()?['Temp']
    • Under the Parallel branch action, add a Compose action, Inputs set to MaximunValue variable and MinimumValue variable.

     

    Image reference:

    15.JPG16.JPG17.JPG18.JPG19.JPG

    The flow works successfullly as below:20.JPG

     

     

    More details about using expression in flow actions, please check the following article:

    Using expression in flow actions

     

    More details about Parallel Branch action in Microsoft Flow, please check the following article:

    https://flow.microsoft.com/en-us/blog/parallel-actions/

     

     

    Best regards,

    Kris

  • Meneghino Profile Picture
    6,949 on at

    Hi all, I find it difficult to believe that the max() expression cannot be used in this case.

    Could @v-micsh-msft or @yoshihirok or anyone else confirm that max() cannot be used and that a loop with for each has to be used?

    I have exactly the same situation/question as @Anonymous 

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 468

#2
Haque Profile Picture

Haque 370

#3
Valantis Profile Picture

Valantis 354

Last 30 days Overall leaderboard