web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Looking for expression...
Power Automate
Answered

Looking for expression to join arrays.

(0) ShareShare
ReportReport
Posted on by 3,340

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.

Categories:
I have the same question (0)
  • PowerBack19 Profile Picture
    679 on at

    @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

  • martinav Profile Picture
    3,340 on at

    @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.

  • martinav Profile Picture
    3,340 on at

    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

  • martinav Profile Picture
    3,340 on at

    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.

  • martinav Profile Picture
    3,340 on at

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

     

    image.png

  • efialttes Profile Picture
    14,756 on at

    @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

  • martinav Profile Picture
    3,340 on at

    @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.

  • efialttes Profile Picture
    14,756 on at

    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!

     

  • Verified answer
    DeepakS Profile Picture
    2,301 Most Valuable Professional on at

    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,

     

     

  • martinav Profile Picture
    3,340 on at

    @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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 227

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard