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?
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
}
]
}
]
}
]
Hey! No worries & no rush. I appreciate any and all help I can get!
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
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.
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
So the array goes (indents for nests)
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:
I want everything from Day 1, but only Lizard from Day 2.
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
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional