Hey,
I have 2 arrays.
[{"Date": "2024-03-04", "Hours": 7},{"Date": "2024-03-05", "Hours": 4},{"Date": "2024-03-06", "Hours": 8}]
and
[{"Date": "2024-03-04", "Work": 7},{"Date": "2024-03-05", "Work": 5},{"Date": "2024-03-08", "Work": 6}]
result i would like to get is:
[{"Date": "2024-03-05", "Hours": 4, "Work": 5}, {"Date": "2024-03-06", "Hours": 8, "Work": 0}, {"Date": "2024-03-08", "Hours": 0, "Work": 6}]
Right now im using the following steps to get these results but its not very time friendly.
is there another way to get these results?
Thanks.
Its not so much of "expected". its to already filter out data to see if certain dates have hours and work isn't equal.
Thank you, with this i can improve my flow a lot.
Select
From
union(
xpath(
xml(json(concat('{"Root":{"Item":', union(outputs('Array0'), outputs('Array1')), '}}'))),
'//Date/text()'
),
json('[]')
)
Map Date
item()
Map Hours
coalesce(
first(
xpath(
xml(json(concat('{"Root":{"Item":',outputs('Array0'), '}}'))),
concat('//Item[Date="', item(), '"]/Hours/text()')
)
),
0
)
Map Work
coalesce(
first(
xpath(
xml(json(concat('{"Root":{"Item":',outputs('Array1'), '}}'))),
concat('//Item[Date="', item(), '"]/Work/text()')
)
),
0
)
Result
[
{
"Date": "2024-03-04",
"Hours": "7",
"Work": "7"
},
{
"Date": "2024-03-05",
"Hours": "4",
"Work": "5"
},
{
"Date": "2024-03-06",
"Hours": "8",
"Work": 0
},
{
"Date": "2024-03-08",
"Hours": 0,
"Work": "6"
}
]
Why is this not part of your expected result?
@Robby_WW Can you switch to the Classic Designer and upload a screenshot where all the actions are expanded. It would help to provide more context.
In the meantime, the reason why your flow is taking a long time to run is due to the logic in your flow. Particularly the nested Apply to Each actions.
Take a look a this YT Tutorial I recently uploaded: 3 Mistakes YOU 🫵 are Making with the Apply to Each Action in your Microsoft Power Automate Flow
In this video tutorial I’ll go over how to avoid these common mistakes when using the Apply to Each action in a Power Automate flow:
1️⃣ Looping through a Single Item
2️⃣ Creating Unnecessary Nested Loops
3️⃣ Looping through an Unfiltered Array
At the end of the video I share a few helpful insights when it comes to using the Apply to Each action in your flow.
I'll also cover:
✅ How to avoid the Apply to Each action with a single item array
✅ How to use the item() function to access dynamic content in an array
✅ How to prevent unnecessary nested Apply to Each action loops
✅ How to use the Select action
✅ How to convert an array to a string with the Select action
✅How to use the Filter Query field
✅ How to count the number of items in an array
✅ How to use a condition control
✅ How to use the concurrency control
✅ How to set a top count
✅ How to use Compose actions for troubleshooting
Hope this helps!
If I helped you solve your problem—please mark my post as a solution ✅. Consider giving me a 👍 if you liked my response! If you're feeling generous— ☕️ Buy me a coffee: https://www.buymeacoffee.com/acreativeopinion |
Michael E. Gernaey
566
Super User 2025 Season 1
David_MA
516
Super User 2025 Season 1
stampcoin
492