cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenDonahue
Skilled Sharer
Skilled Sharer

Filtering an array of objects for a property in the objects

I the following array, I need to access all the elements in the array where "QOrder": "1" (there will always only be one element):

 

[
  {
    "@odata.etag""",
    "ItemInternalId""4e0e6adf-b08c-47b9-83e3-24440c1eaad1",
    "Q-ID""21",
    "QGroup""Std1",
    "Q""Why is question3 hard?",
    "QOrder""9"
  },
  {
    "@odata.etag""",
    "ItemInternalId""f7ff0d03-c360-413e-af41-ef720c9a40a5",
    "Q-ID""22",
    "QGroup""Std1",
    "Q""Is question1 present?",
    "QOrder""1"
  },
  {
    "@odata.etag""",
    "ItemInternalId""4f6f2703-cee6-4f96-b8de-1df90fbfcc2b",
    "Q-ID""23",
    "QGroup""Std1",
    "Q""Where is question 2?",
    "QOrder""2"
  }
]
 
I tried this code in a Filter array block, but with no luck:
item()?['QOrder'] is equal to string(1) (I also tried "... is equal to int(1)")
Array address.png
I don't believe I am accessing the value in QOrder correctly.
Would someone please lend a hand? I would be very appreciative; thank you.
1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

Hi @BenDonahue ,

 

It seems that you have used Parse JSON to parse this array, you can directly use Filter array to filter items.

105.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-bacao-msft
Community Support
Community Support

 

Hi @BenDonahue ,

 

It seems that you have used Parse JSON to parse this array, you can directly use Filter array to filter items.

105.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

So, is the output of a Filter array a JSON object? It begins and ends with square brackets, [ ] , so I'm confused why a Parse JSON should be employed and why I am unable to access the data in the array with something like

body('C-FA-QForQuestionsIndex')?[1]['QOrder']
Also, thank you for your help, @v-bacao-msft .

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,020)