I have a Power Automate flow which returns an array of results from a SharePoint list. One of the fields (Stops) is a JSON array stored as a string. Using some schema manipulation, I am able to transform my results to the following stored as the output of a Filter Array action called Create TripsArray
[
{
"Trip": "My first Trip",
"Stops": [
{
"Location": "New York",
"Food": "Good"},
{
"Location": "California",
"Food": "Bad"
}
]
},
{
"Trip": "My second Trip",
"Stops": [
{
"Location": "California",
"Food": "Good"},
{
"Location": "Washington",
"Food": "Bad"
}
]
},
{
"Trip": "My Last Trip",
"Stops": [
{
"Location": "Washington",
"Food": "Good"},
{
"Location": "Rhode Island",
"Food": "Bad"
}
]
}
]
I would like to run a Power Automate flow to create a dynamic array of Places (strings) and return only those objects where one of the Stops was in a Place.
example:
TargetPlaces: ['Washington', 'Rhode Island']
expected return: [{"Trip": "My second Trip"}, {"Trip": "My Last Trip"}]
Ultimately, I would like to count how many Trips are returned, but I know I can do that with length()
CoPilot has suggested using intersection() and I've tried
intersection(body('Create_TripsArray')?['Trip']?['Stops']),outputs('Compose_TargetPlaces'))
error: 'Trip' cannot be selected. Array elements can only be selected using integer index.
Specific documentation suggestions with links would be welcomed!