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:
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-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?
Solved! Go to Solution.
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:
[ { "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 } ]
item()?['temperature']
first(body('Select'))?['Temp']
first(body('Select'))?['Temp']
@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']
Image reference:
The flow works successfullly as below:
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
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.
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:
[ { "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 } ]
item()?['temperature']
first(body('Select'))?['Temp']
first(body('Select'))?['Temp']
@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']
Image reference:
The flow works successfullly as below:
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
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
User | Count |
---|---|
92 | |
73 | |
43 | |
27 | |
26 |
User | Count |
---|---|
42 | |
28 | |
25 | |
24 | |
20 |