cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Comparing elements of two string arrays

Hello Flow Community!

 

I would like to "compare" elements in two arrays, like eg.:

 

Array1 ["apple", "orange", "banana"];

Array2 ["strawberry", "apple", "watermelon"];

 

the thing is that if at least one element (string) is the same in both arrays i would like to eg. send a message.

 

Did anyone tried something like this, or could give me some hints how to achieve that? 

 

Thanks in advance! 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Comparing elements of two string arrays

Hi @bryq3 ,

 

If this comparison does not consider index, but if it has the same element value, it need to send email. You could refer to the following method.

 

  • Initialize three variables, two array variables to store the array to be compared, and the integer variable to record how many equal element values.
  • Iterate through the array 1 and determine if array 2 contains the elements in array 1 that are currently traversed. If they are equal, the value of the integer variable is incremented by 1.
  • Finally, determine whether the value of integer is equal to 0. If it is not equal to 0, it means that the two elements have the same elements.

 

Image reference:37.PNG

38.PNG39.PNG

 

Hope it helps.

 

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
Community Support
Community Support

Re: Comparing elements of two string arrays

Hi @bryq3 ,

 

If this comparison does not consider index, but if it has the same element value, it need to send email. You could refer to the following method.

 

  • Initialize three variables, two array variables to store the array to be compared, and the integer variable to record how many equal element values.
  • Iterate through the array 1 and determine if array 2 contains the elements in array 1 that are currently traversed. If they are equal, the value of the integer variable is incremented by 1.
  • Finally, determine whether the value of integer is equal to 0. If it is not equal to 0, it means that the two elements have the same elements.

 

Image reference:37.PNG

38.PNG39.PNG

 

Hope it helps.

 

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
Frequent Visitor

Re: Comparing elements of two string arrays

Hi @v-bacao-msft 

 

It works and that is exactly what i was looking for 🙂 

 

Thank you vary much!

Highlighted
Kudo Collector
Kudo Collector

Re: Comparing elements of two string arrays

I have tried this method to compare two arrays and if the item doesnt exist in the second list to create it but when I run it again it creates all the items in the array again not just the new item.

 

Is there a way to loop through all the items and just create the new items?  I will also want to update if there is something changed...

 

I am trying to do a one way sync with Azure SQL table to sharepoint online list.

Helpful resources

Announcements
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (10,486)