cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Break up a nested array, Extract desired Values, Keep associated Key Value Challenge

Hello here

 

I would really appreciate assistance in resolving this seemingly tricky nested array that just won't let go of its values.

Essentially, I have an output from a previous step which returns a nested array. Please see image below for a somewhat simplified example 🙂 

 

Example of nested arrayExample of nested array

 

I have tried all sorts of things to try and achieve the desired outcome below. Please see image below.

 

Desired OutcomeDesired Outcome

 

Ultimately, I would like to restructure the output from first image within a SELECT data operation (if possible) and send the end result on as an HTML table.

Please note that the desired outcome keeps the Associated Data Value result for each ItemID. 

 

The most promising/very frustrating approach has been in using the "Append to string" or "Append to array" actions with Apply to Each actions, but my attempts have just resulted in all the values being returned for each ItemID. That is, for the example shown, ItemID 30, 31 and 32 each end up with the same ["Apple", "Avocado", "Banana", "Coconut"]. "Append to string" does not seem to reset for each ItemID, no matter the nested apply to each configurations I have tried. 

 

I really hope some of you can suggest how to approach this.

 

Many thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Break up a nested array, Extract desired Values, Keep associated Key Value Challenge

Hello @mo_jo_jo 

After you have identified the item, before the inner loop, add a Set variable action in which you set the variable varStore to null!

The value "null" is made by using the Expression panel!

That way, you make sure that the values that you append to the variable are only those related to the identified item.

Try it out and tell us how it went 🙂
Kind regards, John

View solution in original post

4 REPLIES 4
Highlighted
Super User II
Super User II

Re: Break up a nested array, Extract desired Values, Keep associated Key Value Challenge

Hello @mo_jo_jo 

Your idea about using Append to array while looping on Items and on the AssociatedData is fine. You just need to make sure your clear the variables that you use to collect the values, before you start on the AssociatedDate of the next item.

Show us what you already got in the flow and we can provide suggestions 🙂

Kind regards, John

Highlighted
Frequent Visitor

Re: Break up a nested array, Extract desired Values, Keep associated Key Value Challenge

@JohnAageAnderse 

Thanks for the response. Please see attached image and the end result shown in highlighted Flow Test - 3.

As you can see, each ID just gets everything in the appended string at the end of the apply to each(es) 🙂

I don't know how to stop/reset the variable after each outer run.

Can you suggest some steps that I can add to achieve a result where I only obtain values relevant to a respective ID?

 

Flow setup and current resultFlow setup and current result

 

Highlighted
Super User II
Super User II

Re: Break up a nested array, Extract desired Values, Keep associated Key Value Challenge

Hello @mo_jo_jo 

After you have identified the item, before the inner loop, add a Set variable action in which you set the variable varStore to null!

The value "null" is made by using the Expression panel!

That way, you make sure that the values that you append to the variable are only those related to the identified item.

Try it out and tell us how it went 🙂
Kind regards, John

View solution in original post

Highlighted
Frequent Visitor

Re: Break up a nested array, Extract desired Values, Keep associated Key Value Challenge

@JohnAageAnderse 

Annoyingly simple 🤔

There still seems to be an issue with SELECT still keeping the result of every iteration of each "ItemID" but I think I can resolve that by creating some new variables. 

 

I recollect trying to use the Set Variable action (for the first time) in one of my many many attempts/approaches to solve the business problem I am trying to produce the flow for but I must have used it within the wrong (inner) loop, because Flow would not allow setting the variable; I guess because it was in use.

I got annoyed and took the business flow apart to start from scratch thinking the approach wouldn't work, when I was not too far off. 

Will take this new learning into tackling that flow again 😀 

Thank you.

Helpful resources

Announcements
Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Top Solution Authors
Top Kudoed Authors
Users online (6,445)