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 / Filtering Nested JSON ...
Power Automate
Answered

Filtering Nested JSON Arrays

(0) ShareShare
ReportReport
Posted on by 6

Hi all,

 

I have a JSON (see below) which contains a series of form submissions. Each submission includes a formSubmissionId and a series of fields with their corresponding fieldReferenceId and fieldValue.

 

What I want to do is produce a new array listing all the records where the fieldReferenceId '18c837cd-1dae-4961-9164-3de23e9c954b' has a fieldValue of 'a1GJ7000000sZ9cMAE'.

 

In the example JSON below, there are two submitted records. I want to extract only the second one, because it has a fieldValue of 'a1GJ7000000sZ9cMAE' for the fieldReferenceId '18c837cd-1dae-4961-9164-3de23e9c954b'.

 

Due to the potential size of the data, I believe using a 'FilterArray' would be more efficient than nested 'Apply To Each' actions.

 

I really appreciate any help with this.

 

Thanks.

 

{
 "statusCode": 200,
 "headers": {
 "Date": "XXXXXX",
 "Content-Type": "XXXXXX",
 "Content-Length": "XXXXXX"
 },
 "body": {
 "data": [
 {
 "formId": 72684,
 "formSubmissionId": 123456789,
 "createdTimeStamp": "2024-05-16T08:26:29.913",
 "modifiedTimeStamp": "2024-05-16T08:26:29.93",
 "fields": [
 {
 "fieldReferenceId": "d9005789-8b54-4b24-ab44-16723ae7ddfc",
 "fieldValue": "123, Apple Road"
 },
 {
 "fieldReferenceId": "a6e7ace1-f4cb-4c2d-894d-73693164d82f",
 "fieldValue": "sn9 2uh"
 },
 {
 "fieldReferenceId": "18c837cd-1dae-4961-9164-3de23e9c954b",
 "fieldValue": "0WOJ7000000XsXyOAK"
 }
 ],
 "userGroups": [],
 "assignedToUsers": [],
 "unassignedFromUsers": []
 },
 {
 "formId": 9347,
 "formSubmissionId": 6299592,
 "createdTimeStamp": "2024-05-16T08:26:29.913",
 "modifiedTimeStamp": "2024-05-16T08:26:29.93",
 "fields": [
 {
 "fieldReferenceId": "d9005789-8b54-4b24-ab44-16723ae7ddfc",
 "fieldValue": "456 Orange Crescent"
 },
 {
 "fieldReferenceId": "a6e7ace1-f4cb-4c2d-894d-73693164d82f",
 "fieldValue": "sw3 8rf"
 },
 {
 "fieldReferenceId": "18c837cd-1dae-4961-9164-3de23e9c954b",
 "fieldValue": "a1GJ7000000sZ9cMAE"
 }
 ],
 "userGroups": [],
 "assignedToUsers": [],
 "unassignedFromUsers": []
 }
 ]
 }
}

 

Categories:
I have the same question (0)
  • Verified answer
    Chriddle Profile Picture
    8,640 Super User 2026 Season 1 on at

    Chriddle_0-1715879775206.png

    Compose (your JSON)

    Spoiler (Highlight to read)
    {
     "statusCode": 200,
     "headers": {
     "Date": "XXXXXX",
     "Content-Type": "XXXXXX",
     "Content-Length": "XXXXXX"
     },
     "body": {
     "data": [
     {
     "formId": 72684,
     "formSubmissionId": 123456789,
     "createdTimeStamp": "2024-05-16T08:26:29.913",
     "modifiedTimeStamp": "2024-05-16T08:26:29.93",
     "fields": [
     {
     "fieldReferenceId": "d9005789-8b54-4b24-ab44-16723ae7ddfc",
     "fieldValue": "123, Apple Road"
     },
     {
     "fieldReferenceId": "a6e7ace1-f4cb-4c2d-894d-73693164d82f",
     "fieldValue": "sn9 2uh"
     },
     {
     "fieldReferenceId": "18c837cd-1dae-4961-9164-3de23e9c954b",
     "fieldValue": "0WOJ7000000XsXyOAK"
     }
     ],
     "userGroups": [],
     "assignedToUsers": [],
     "unassignedFromUsers": []
     },
     {
     "formId": 9347,
     "formSubmissionId": 6299592,
     "createdTimeStamp": "2024-05-16T08:26:29.913",
     "modifiedTimeStamp": "2024-05-16T08:26:29.93",
     "fields": [
     {
     "fieldReferenceId": "d9005789-8b54-4b24-ab44-16723ae7ddfc",
     "fieldValue": "456 Orange Crescent"
     },
     {
     "fieldReferenceId": "a6e7ace1-f4cb-4c2d-894d-73693164d82f",
     "fieldValue": "sw3 8rf"
     },
     {
     "fieldReferenceId": "18c837cd-1dae-4961-9164-3de23e9c954b",
     "fieldValue": "a1GJ7000000sZ9cMAE"
     }
     ],
     "userGroups": [],
     "assignedToUsers": [],
     "unassignedFromUsers": []
     }
     ]
     }
    }
    { "statusCode": 200, "headers": { "Date": "XXXXXX", "Content-Type": "XXXXXX", "Content-Length": "XXXXXX" }, "body": { "data": [ { "formId": 72684, "formSubmissionId": 123456789, "createdTimeStamp": "2024-05-16T08:26:29.913", "modifiedTimeStamp": "2024-05-16T08:26:29.93", "fields": [ { "fieldReferenceId": "d9005789-8b54-4b24-ab44-16723ae7ddfc", "fieldValue": "123, Apple Road" }, { "fieldReferenceId": "a6e7ace1-f4cb-4c2d-894d-73693164d82f", "fieldValue": "sn9 2uh" }, { "fieldReferenceId": "18c837cd-1dae-4961-9164-3de23e9c954b", "fieldValue": "0WOJ7000000XsXyOAK" } ], "userGroups": [], "assignedToUsers": [], "unassignedFromUsers": [] }, { "formId": 9347, "formSubmissionId": 6299592, "createdTimeStamp": "2024-05-16T08:26:29.913", "modifiedTimeStamp": "2024-05-16T08:26:29.93", "fields": [ { "fieldReferenceId": "d9005789-8b54-4b24-ab44-16723ae7ddfc", "fieldValue": "456 Orange Crescent" }, { "fieldReferenceId": "a6e7ace1-f4cb-4c2d-894d-73693164d82f", "fieldValue": "sw3 8rf" }, { "fieldReferenceId": "18c837cd-1dae-4961-9164-3de23e9c954b", "fieldValue": "a1GJ7000000sZ9cMAE" } ], "userGroups": [], "assignedToUsers": [], "unassignedFromUsers": [] } ] } }

    Select

    From

    xpath(
    	xml(
    		json(
    			concat(
    				'{"Root":', outputs('Compose'), '}'
    			)
    		)
    	),
    	'//data[fields[fieldReferenceId="18c837cd-1dae-4961-9164-3de23e9c954b" and fieldValue="a1GJ7000000sZ9cMAE"]]'
    )

    Map

    json(item())['data']

     

    Result

    [
     {
     "formId": "9347",
     "formSubmissionId": "6299592",
     "createdTimeStamp": "2024-05-16T08:26:29.913",
     "modifiedTimeStamp": "2024-05-16T08:26:29.93",
     "fields": [
     {
     "fieldReferenceId": "d9005789-8b54-4b24-ab44-16723ae7ddfc",
     "fieldValue": "456 Orange Crescent"
     },
     {
     "fieldReferenceId": "a6e7ace1-f4cb-4c2d-894d-73693164d82f",
     "fieldValue": "sw3 8rf"
     },
     {
     "fieldReferenceId": "18c837cd-1dae-4961-9164-3de23e9c954b",
     "fieldValue": "a1GJ7000000sZ9cMAE"
     }
     ]
     }
    ]
  • ATarrant Profile Picture
    6 on at

    Thanks Chriddle - worked like a charm!

  • ATarrant Profile Picture
    6 on at

    Hi Chriddle,

    I was just using your expression, and I want to change the static 

    fieldValue="a1GJ7000000sZ9cMAE"

    To a dynamic value earlier within the same flow. The reference to the dynamic value is:

    triggerBody()?['body']?['VisitID']

     Would you be able to tweak y our expression to accept this? I've tried with the expression below, and whilst it runs, it doesn't return any records, when it should:

    xpath(
    	xml(
    		json(
    			concat(
    				'{"Root":', outputs('GetDataCollector'), '}'
    			)
    		)
    	),
    	'//data[fields[fieldReferenceId="18c837cd-1dae-4961-9164-3de23e9c954b" and fieldValue=triggerBody()?['body']?['VisitID']]]'
    )

     

  • Chriddle Profile Picture
    8,640 Super User 2026 Season 1 on at

    You have to concat this into the xpath string:

     

    xpath(
    	xml(
    		json(
    			concat(
    				'{"Root":', outputs('Compose'), '}'
    			)
    		)
    	),
    	concat(
    		'//data[fields[fieldReferenceId="18c837cd-1dae-4961-9164-3de23e9c954b" and fieldValue="',
    		triggerBody()?['body']?['VisitID'],
    		'"]]'
    	)
    )

     

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 304

#2
David_MA Profile Picture

David_MA 245 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 243 Most Valuable Professional

Last 30 days Overall leaderboard