PPIM_RPA
(PPIM RPA)
May 30, 2023, 3:29pm
1
Hello UiPath Forum Experts,
I’m looking for a way to compare three arrays and return the items common to all three.
Example
Array 1: Email address; mailing address; Company; Country
Array 2: Email address; First Name; Last Name; Company; Country; Job Title
Array 3: Email address; University; Company; Country
In the above example, the results should be: Email Address; Company; and Country.
Thank you in advance.
You make life better for all of us.
Hi @PPIM_RPA ,
You could maybe try using the Intersect
method :
array1.Intersect(array2).Intersect(array3).ToArray
array1
, array2
, array3
are variables of type Array of String.
Visual :
2 Likes
Parvathy
(PS Parvathy)
May 31, 2023, 4:41am
3
Hi @PPIM_RPA
Follow the below steps to achieve the required output:
Initialize three arrays namely Array1,Array2,Array3 and give the following requied array. Datatype is Array(string).
Array1= {“Email address”, “mailing address”, “Company”, “Country”}
Array2= {“Email address”, “First Name”, “Last Name”, “Company”, “Country”, “Job Title”}
Array3= {“Email address”, “University”, “Company”, “Country”}
Initialize an variable commonItems and datatype is Array(String).
Take assign activity and by using Intersect method you can achieve the required output. Below are the syntax:
commonItems= Array1
commonItems= commonItems.Intersect(Array2).Intersect(Array3).ToArray()
For For each Loop to achieve the output.
Note: Refer the below workflow file for reference.
Common Items in an Array.xaml (10.5 KB)
Hope it helps!!
Regards
PPIM_RPA
(PPIM RPA)
May 31, 2023, 3:09pm
4
Thank you for your detailed description with code.
Just confirmed that this works.
Appreciate it
1 Like
system
(system)
Closed
June 3, 2023, 3:09pm
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.