cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martinav
Community Champion
Community Champion

Looking for expression to join arrays.

I thought I saw this before, but after an hour of looking, I cant find it.  Simply put.  I have two arrays, with a common DocumentID.  I just need to JOIN them goether ON DocumentID (using SQL lingo)

 

Array1:

 

 

[
  {
    "DocumentID": 1265,
    "PartNumber": "510009",
    "Rev": "1",
    "Description": "KBOV HANDLE BRACKET ASSEMBLY"
  },
  {
    "DocumentID": 2338,
    "PartNumber": "KBV8-N-FW",
    "Rev": "0",
    "Description": "KBV8-N-FW GENERAL ARRANGEMENT & BOM"
  },
  {
    "DocumentID": 5522,
    "PartNumber": "213155",
    "Rev": "0",
    "Description": ".125 X .50 DOWEL PIN CS"
  }
 
]

 

 

 

Array2:

 

 

[
  {
    "DocumentID": 1265,
    "Comment": "."
  },
  {
    "DocumentID": 2338,
    "Comment": "Exploded view still WIP."
  },
  {
    "DocumentID": 5522,
    "Comment": "."
  }

]

 

 

 

This is what I want:

 

 

 

[
  {
    "DocumentID": 1265,
    "PartNumber": "510009",
    "Rev": "1",
    "Description": "KBOV HANDLE BRACKET ASSEMBLY",
    "Comment": "."
  },
  {
    "DocumentID": 2338,
    "PartNumber": "KBV8-N-FW",
    "Rev": "0",
    "Description": "KBV8-N-FW GENERAL ARRANGEMENT & BOM",
    "Comment": "Exploded view still WIP."
  },
  {
    "DocumentID": 5522,
    "PartNumber": "213155",
    "Rev": "0",
    "Description": ".125 X .50 DOWEL PIN CS",
    "Comment": "."
  }
 
]

 

 

 

I'm sure there is a simple expression for this.

1 ACCEPTED SOLUTION

Accepted Solutions
DeepakS
Most Valuable Professional
Most Valuable Professional

Hi @martinav 

 

I am not sure if you have already solved your issue but i find this interesting and thought of  spending some time on it. i finally able to make it work (dont think its a best solution and i may need to work on improving it) but its working.

i uploaded working flow at github: 

https://github.com/DeepakS22/DPowerAutomate/blob/master/MergeJSON_20200327174700.zip

 

Have a look and let me know if that helps.

 

Regards,

 

 

View solution in original post

15 REPLIES 15
PowerBack19
Impactful Individual
Impactful Individual

@martinav - Have you tried using the "Append to an Array variable"? Here is a video that covers this: https://www.youtube.com/watch?v=VAfwiN-vARQ

@PowerBack19 ,

 

Append adds records.  It does not add items, or "columns" depending on data source.  If you see my data examples, its merging or joining records keyed on DocumentID.  Again, terms depending on the system you are familiar with, SP, SQL, etc.

I could get there if there is a way to use an expression to get the current item() from these two select functions.  I could combine together.  Of course none of the attempts to write the expression work.

 

image.png

 

Results:

 

image.png

Ive wasted an entire day on this.  This is one of those times I loathe this system.  This is so forking simple.  Has to be a way to do it.

Cant go back to the filter array either.  This is absurd.

 

image.png

@martinav 

WDL limitations are usually frustrating.

I have managed to join elements from two different arrays (lets call them 'myInput1Array' and 'myInput2Array') when both elements shared a common property value, but it is very time consuming both on the design and on the performance.

 

So, you need to initialize a third array variable, let's call it 'myOutputArray', leave it empty for the moment.

Now, you use an Apply to each and assign as its input 'myInput1Array'

Inside the Apply to Each, you add a Filter Array and assign as its input 'myInput2Array', try to match common property value from current Apply to each iteration. Now you make sure a single match, if so, Append to array variable, name 'myOutputArray', value:

setProperty(setProperty(setProperty(json('{}'),'Property1FromArray1Name','Value'),'CommoProperty','Value'),Property1FromArray2Name','Value')

So, property values from myInput1Array are obtained from 

items('Apply_to_each')

And, property values from myInput2Array are obtained from

first(body('Filter_array'))

As I mentioned, very inneficient but saved my day

Hope this helps

Did I make your day? If so, mark my response as 'Solution' !!!

También escribo sobre Power Automate en este Blog y en Twitter

@efialttes ,

 

You have NO idea how much I appreciate the help of others here.  I am working through this solution.  I think of myself as pretty savvy with this type of thing, but I will tell you.  The absolute convolution of how many things work in this system is very troubling.  I am completely dumbfounded on how people come up with solutions like this.  Even with the answer right in front of me, and using the SAME names, etc, it is still very difficult to get everything right to make it work.  I'm still working on it, and will report back when its working.  I need to implement this solution to several flows.

 

Its funny, because to do the exact same thing in powerapps is also a trick. I can get my head around it better, but it took a while to figure out the ForAll() statement.  What is sooo simple in SQL (JOIN statement).  I still have to study what I did on other apps in order to use it again, but I have a solution on that side of the power platform.  I do find it interesting that these tools are designed as "code free", but when it comes down too it, you have to know more different types of code in order to get things to work the way you want.  If you are super simple, you can get out of it, but if you do anything of real depth, then you have to figure out MANY different languages.  ODATA, JSON, and Expressions (flow) just to name a couple.  Doing the same type of thing in PowerApps compared to Flow is an entirely different animal and requires very different knowledge.

 

Sorry, I'm whining a bit.  I'll report on progress.

Hi!

I understand your concerns: PowerApps with its own language, Power Automate too, ODATA... sometimes is a bit frustrating... The dream of zero code is still a dream, even thought Microsoft is putting lots of efforts to help us

Hope your story will have a happy ending... please let us know your progress on your challenge

Thanx!

 

Did I make your day? If so, mark my response as 'Solution' !!!

También escribo sobre Power Automate en este Blog y en Twitter

DeepakS
Most Valuable Professional
Most Valuable Professional

Hi @martinav 

 

I am not sure if you have already solved your issue but i find this interesting and thought of  spending some time on it. i finally able to make it work (dont think its a best solution and i may need to work on improving it) but its working.

i uploaded working flow at github: 

https://github.com/DeepakS22/DPowerAutomate/blob/master/MergeJSON_20200327174700.zip

 

Have a look and let me know if that helps.

 

Regards,

 

 

@DeepakS ,

 

Oh, I most certainly have not resolved my issue.  I thought it would be easy to just make a SQL View, because it is a simplified form of a view I already have.  However, that also is failing, and I have beat on it for several hours.  Side-by side comparison with an existing, and its been expressly perfect, but does not work.  I'm about to bail on this.

 

However, I was surprised by your post.  Of course, I'm confronted once again with an unknown, and unintuitive task... which is how the hello do you import a flow from what you have given.  Especially since I had no idea that you could even export them.  

 

I will try it if this task is not a multi-hour challenge.

 

Any direction on where to go to do this?

 

Thank you.

DeepakS
Most Valuable Professional
Most Valuable Professional

Hi @martinav 

 

Yes you can export/import. to import my flow just download it as it is and import here is an screen:

Import.png

 

@DeepakS ,

 

Interesting.  I have never seen that...

 

Trying it...

 

 

@DeepakS ,

 

Huh, well, lookie there.  That works.  I was dancing around this for hours.  Looks like you saved me a few more.

 

Nice job!

@DeepakS ,

 

A little update.  I added an additional source to merge.  Thus, I'm merging three arrays together.  Its as "simple" (after getting all of the syntax, language and usage correct) as adding another nested loop.  The disadvantage to this is it took over 2 minutes to run this part of the flow with 6 items in the items being acted upon.  Its only a once a day notification, so PA isnt waiting on it.  But, it is something to keep in mind.  Even two loops deep with 6 items tool over a minute to execute.  This will never be a large number.  I doubt it ever gets over 10 items, but that is something to consider with this method.  Of course, I'm not sure there is another method out there.  This is by far the simplest I saw.  Props to @DeepakS  for this!

 

image.png

DeepakS
Most Valuable Professional
Most Valuable Professional

Hi @martinav 

 

Yes , even i am not fully like my approach but as of now cant think of any other method, as we are merging two multi filed JSON :(. i can tell its complex in C# too ;).

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (4,769)