cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
v-bacao-msft
Community Support
Community Support

 

Hi @Anonymous ,

 

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
fchopo
Super User
Super User

Hello @Anonymous 

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!
v-bacao-msft
Community Support
Community Support

 

Hi @Anonymous ,

 

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.
Anonymous
Not applicable

@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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,920)