Context: In my flow I have a for each loop to loop through a JSON array.
The output of each loop is another JSON array, which I want to use to to add a new row to a spreadsheet (the first action in the loop is a Parse JSON to ensure it's recognized as a json array)
{
"status": "success",
"data": [
{
"id": "X1",
"value": "example"
},
{
"id": "X23",
"value": "example"
},
{
"id": "X16",
"value": "example"
}
}
In the 'Add row into table' action I want an expression that selects the right 'value' for each column of the table based on the 'id', but I can't figure out how to write the expression.
Chat-GPT suggests an expression like this would work, but I can't make it:
first(
filter(
body(item()),
item().id == 'X16'
))?['value']
There is no expression/function like 'filter' in Power automate. I faced a similar thing and ChatGPT suggested a similar expression. You have to use the Filter Array function to find the eligible items as shown below. (remebber to input 'data' array from your JSON not the full JSON - this is to be used within the loop that generates this JSON)
once done, you can use this expression first(body('Filter_array'))?['value']
to retrieve the value as needed.