Common or uncommon items between two Lists UiPath
In every automation, for the business processes, we use Lists to store a set of values.
How we can find the common and uncommon values between those two Lists in UiPath?
First, let’s see how we can achieve that, and later we will move into the implementation using UiPath.
Let’s say we have two Lists named as below:
- List1
- List2
When we wanted the data which is common from both Lists, we need to use the below method:
Intersect() –
Intersect returns the common values from both lists and stores them in the new list.
When we wanted the data which is uncommon from both Lists, we need to use the below method:
Except() –
Except returns the uncommon values from both lists and stores them in the new list.
Now by using these two methods we will implement in UiPath.
Step1: Drag an Assign activity into the designer panel and initialize the List1 with some sample data as shown below:
Step2: Drag an Assign activity into the designer panel and initialize the List2 with some sample data as shown below:
As we have List1 and List2 are ready, let’s see how we can get common values from both lists.
Because the intersect method returns a list, in order to see all the common values used for each as shown below:
The output for this is: The common values are 1,9
Let’s see how we can get uncommon values from both lists.
As the except method also returns a list, in order to see all the uncommon values used for each as shown below:
The output for this is: The uncommon values are 2,3,5
This is how we separate the common and uncommon values from lists in UiPath.