Hi, I am working on a flow currently but now I am stuck.
I have an Main-Array that looks like this:
[
{
"id": 1,
"hours": 10
},
{
"id": 1,
"hours": 12
},
{
"id": 1,
"hours": 8
},
{
"id": 2,
"hours": 5
},
{
"id": 3,
"hours": 10
},
{
"id": 3,
"hours": 11
}
]
Now I want to sum-up the hours per id => result should be:
[
{
"id":1,
"total":30
},
{
"id":2,
"total":5
},
{
"id":3,
"total": 21
}
]
Any idea how I can achieve this?
Ps.: I can manage to provide the array sorted already. So there will always be an ascending ID 1,2,3,4 etc... if this plays a role (i guess so).
Any help much appreciated!!!
@Anonymous
Hi there. So, this one was interesting and I was surprised there wasn't an easier way, or more information on this. I'm working on documenting this in more detail, but here's the broad strokes of what I did..it's not super performant, so I'd be interested to see how other people handle it, but here you go:
This way, it will cycle through however many ID's you have and get the correct amounts for each. Once it's cycle through them all, it will leave the Do Until loop, and that's where we pick up our output. I just added a Compose and put the output from varOutput in there. This was my result:
If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.
@Anonymous
Here is the blog post with more details:
Group By and Sum in Power Automate / Flow
Best of luck.
-Ed
If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.