I am looking for a way to compare two array objects. Both the objects have email address and I want only those email address that are unique to the second one.
For example -
Array1 - [ firstname.lastname@example.org, email@example.com, firstname.lastname@example.org]
Array2 - [ email@example.com, firstname.lastname@example.org, email@example.com]
What I want is -> firstname.lastname@example.org.
Basically opposite of intersection operation.
If not with array, is it possible to get this using string?
Do you want to compare two array objects and find the unique elements within the second array?
I have made a test on my side and please take a try with the following workaround:
Within "If/no" branch of Condition, add a "Append to array variable" action, Name set to UniqueEmails variable, Value set to following formula:
The flow works successfully as below:
More details about using expression in flow actions, please check the following article:
If you want to compare two strings (compare characters within two strings), I afraid that there is no direct way to achieve your needs in Microsoft Flow currently.
This is awesome! thank you.
Question: what if i wanted to find unique records based on a difference in a single field?
if Array1 has a "Title" Field and an "Email" field
and Array 2 has a "Title" field and an "Email" field
I want to populate ArrayUniqueEmails only where the title doesn't exist?
Can this be done?
Hi, @v-xida-msft , this looks great ... however there's no option to edit the condition in advanced mode. How do we get there?
Figured it out, I'm an idiot, but others may be as dumb as me.
I actually found a better way for comparing two arrays without Apply to Each loop
equals(length(intersection(variables('Array 1'),variables('Array 2'))),length(variables('Array 1')))
True MVP! This is the fastest way to compare two arrays and return the difference from one of them.
You can repeat the function and swap out the sources in the From and Contains parameters to return the difference for both.
I must have seen a dozen different solutions from Microsoft support staff that could not provide this elegant formula. THANK YOU!
Check out the News & Announcements to learn more.
Participate in the Power Virtual Agents Community Challenge
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.
Check out our new Discover Your Career Path blog post series and get all the details.