cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mo_jo_jo
Advocate I
Advocate I

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

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
JohnAageAnderse
Memorable Member
Memorable Member

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

@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

 

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

@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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (2,412)