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

Intersect two array of objects

Hi, I have two arrays of objects and I would like to intersect them with the intersection expression. Is that some how possible?

Array1

[
  {
    "NR""32097"
  },
  {
    "NR""32050"
  },
  {
    "NR""00005"
  }
]
 
Array2
[
  {
    "NR""32050",
    "GUID""c6839d05-d326-df11-987c-00155d003a1e"
  },
  {
    "NR""12005",
    "GUID""ca72aef5-fae5-e511-80de-5065f38a69b1"
  },
  {
    "NR""12006",
    "GUID""f2ff98b8-2793-de11-8125-00155da49631"
  }
]
 
I would like to intersect the two arrays based on "NR"
 
intersection(body('Array1')?['NR'],body('Array2')?['NR'])
 
and get something like
 
Result
[
  {
    "NR""32050",
    "GUID""c6839d05-d326-df11-987c-00155d003a1e"
  }
]
 
Can I do that with out using a "for-each" loop? So far I have not found the right soltuion.
Your help is appreciated.
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

 

Hi @Tobiwan ,

 

It seems that using expression alone cannot achieve such a demand.

Please refer to the following configuration:

Spoiler
119.PNG120.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Highlighted
Super User II
Super User II

Hello @Tobiwan 

You can't use intersection function because it expects two arrays of the same object, and in your case these objects are different (first one has NR field only and second one has it and GUID).

So you will probably need a for each expression to get Array1 items, and filter them in the Array2.

Hope it helps!

Ferran

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Highlighted
Community Support
Community Support

 

Hi @Tobiwan ,

 

It seems that using expression alone cannot achieve such a demand.

Please refer to the following configuration:

Spoiler
119.PNG120.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted

@v-bacao-msft, @fchopo Thanks for your replies.

 

I will go with v-baco's solution than. However to compare external systems to a CDS table an then trigger action in CDS, it would be greate to have such functionality. Would save a couple api-calls.

 

Kind regards

Tobi

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

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.

Top Solution Authors
Top Kudoed Authors
Users online (9,770)