New to Power Automate and struggling with an expression.
My flow basically takes multiple data from a PBI report and sends it as a http post.
Before I do the post I need to validate some data, one data item being 'distance' so what I am trying to do is before I do the http post I set a variable and try and get the biggest distance from the data from PBI then If it's greater than a certain amount do something in a condition.
I can't get the max expression to work, it just throws an error, the only time I've had it working it would only get the first item in the PBI data array not the biggest.
Error I receive is...
Unable to process template language expressions in action 'Set_variable' inputs at line '0' and column '0': 'The template language function 'first' expects its parameter be an array or a string. The provided value is of type 'Null'.
PBI data comes as...
[
{
"JobId": 5267,
"id": 625,
"Distance (km)": 13.64878414881468
},
{
"JobId": 5267,
"id": 1178,
"Distance (km)": 20.659444721556447
},
{
"JobId": 5267,
"id": 1343,
"Distance (km)": 8.097056529573832
}
]
The expression I am using is...
max(outputs('GetPBIData')?[0]?['Distance (km)'])
I need to get the highest distance value from the whole array and check it is within tolerance.
Any ideas on best way to achieve this expression?
See image for reference of my flow...
This is the OOTB concept ...
first(outputs('Compose_Array'))
Compose Array
data.
Note: You must set this to be sequential, i.e. set the concurrency to 1.Condition
operation. The left hand side of the expression is item()['Distance (km)']
, the operand is is greater than
and the right hand side variables('Max Object')['Distance (km)']
.item()
There is an easier, single step way to do this but it will require the use of a premium connector.