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 Apps / Collect only Part of N...
Power Apps
Unanswered

Collect only Part of Nested Array

(1) ShareShare
ReportReport
Posted on by

I have an array that I ClearCollect into a collection of Items, then a nested table for "Days", and then a nested table for "activities." 

 

In the 2nd nested array of "Days", I need to only keep the first item in the array. 

 

So for example, in the first item of days, under day #2, I want to keep only the 1st item category 837. 

 

Before: 

 

[
 {
 "OriginDate": "2024-07-08", 
 "Identifier": 21523, 
 "days": [
 {
 "dayNumber": 1, 
 "activities": [
 {
 "category": 123,
 "sport": true
 }, 
 {
 "category": 435,
 "sport": false
 }
 ]
 }, 
 {
 "dayNumber": 2, 
 "activities": [
 {
 "category": 837,
 "sport": false
 }, 
 {
 "category": 827,
 "sport": true
 }
 ]
 }
 ]
 }, 
 {
 "OriginDate": "2024-07-09", 
 "Identifier": 21523, 
 "days": [
 {
 "dayNumber": 1, 
 "activities": [
 {
 "category": 123,
 "sport": true
 }, 
 {
 "category": 435,
 "sport": false
 }
 ]
 }, 
 {
 "dayNumber": 2, 
 "activities": [
 {
 "category": 837,
 "sport": false
 }, 
 {
 "category": 827,
 "sport": true
 }
 ]
 }
 ]
 }
 ]

Desired After: 

[
 {
 "OriginDate": "2024-07-08", 
 "Identifier": 21523, 
 "days": [
 {
 "dayNumber": 1, 
 "activities": [
 {
 "category": 123,
 "sport": true
 }, 
 {
 "category": 435,
 "sport": false
 }
 ]
 }, 
 {
 "dayNumber": 2, 
 "activities": [
 {
 "category": 837,
 "sport": false
 }
 ]
 }
 ]
 }, 
 {
 "OriginDate": "2024-07-09", 
 "Identifier": 21523, 
 "days": [
 {
 "dayNumber": 1, 
 "activities": [
 {
 "category": 123,
 "sport": true
 }, 
 {
 "category": 435,
 "sport": false
 }
 ]
 }, 
 {
 "dayNumber": 2, 
 "activities": [
 {
 "category": 837,
 "sport": false
 }
 ]
 }
 ]
 }
 ]

 

Any idea how I can do this? 

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,963 Moderator on at

    Hi @Rex2025 

     

    How do you determine which things you want to keep? In your example, you kept both in day 1?

     


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

     

  • Rex2025 Profile Picture
    on at

    So the array goes (indents for nests)

    • Item
      • First level
        • Second level item
        • second level item 
        • Possibly more… a “n” number 
      • first level
        • Second level item
        • possibly more
    • item #2

    It repeats that JSON format. 

    At the first level I want all the items from the first second level, but only the first item from Index, 2 of the second level. 

    So, if it is: 

    • Item 1
      • Day 1
        • Cat
        • dog
        • sheep
      • Day 2
        • Lizard
        • Horse
        • lion

     

    I want everything from Day 1, but only Lizard from Day 2. 

  • Michael E. Gernaey Profile Picture
    53,963 Moderator on at

    Hi @Rex2025 

     

    Nice share thank you.

     

    So you'll have Many Items, all with Day 1 and Day 2. Ok just curious, are there other patterns like this. where Day3 or Day4-7 matter? I just want to either give you the fastest without caring because it won't change, or a strategy to do different patterns before I start.

     

    Thanks!


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Rex2025 Profile Picture
    on at

    My power automate flow that I built is only returning Days 1 & 2, so that is what I will always get.

     

    But where I’ve struggled in the flow is limiting Day 2 to just 1 item. 

    If you have a solution in power automate, my current strategy has been a Select function, then

     

    take(item()?[‘day’], 2)


    That still returns all items though in Day 2. 

     

  • Michael E. Gernaey Profile Picture
    53,963 Moderator on at

    Hi @Rex2025 

     

    I promise I will give you a solution later today, its 130 am and going to bed. But yes can easily give you that when i get back.

     


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Rex2025 Profile Picture
    on at

    Hey! No worries & no rush. I appreciate any and all help I can get! 

  • Rex2025 Profile Picture
    on at

    I wanted to throw in an actual sample of my data to help. 

     

    In the dutyPeriodNumber 2, I want to only keep the first item under "legs" while retaining the array format. 

     

    [
     {
     "sequenceOriginDate": "2024-07-16",
     "sequenceNumber": 28441,
     "sequenceStartDateTime": {
     "localTime": "2024-07-16T04:10:00",
     "gmt": "2024-07-16T09:10:00"
     },
     "sequenceEndDateTime": {
     "localTime": "2024-07-18T16:28:00",
     "gmt": "2024-07-18T21:28:00"
     },
     "dutyPeriods": [
     {
     "dutyPeriodNumber": 1,
     "odMinutes": 577,
     "numberOfLegs": 2,
     "legs": [
     {
     "legNumber": 361,
     "legIndex": 1,
     "blockTime": 215,
     "groundTime": 120
     },
     {
     "legNumber": 1622,
     "legIndex": 2,
     "blockTime": 167,
     "groundTime": 0
     }
     ]
     },
     {
     "dutyPeriodNumber": 2,
     "odMinutes": 376,
     "numberOfLegs": 2,
     "legs": [
     {
     "legNumber": 2827,
     "legIndex": 3,
     "blockTime": 97,
     "groundTime": 80
     
     },
     {
     "legNumber": 2043,
     "legIndex": 4,
     "blockTime": 124,
     "groundTime": 0
     }
     ]
     }
     ]
     }
    ]

     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 413

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
timl Profile Picture

timl 315 Super User 2026 Season 1

Last 30 days Overall leaderboard