Compare item in 2 lists

How do i compare item in 2 list? Currently i have 2 list with the following append(using append item to list activity)

List 1 : A B C D
List 2 : B D

Would want to get true false output

Hi,

What is expected result to the above sample?
Do you need to compare if both lists are exactly same including their order?

Regards,

  1. Initialize a Boolean variable to store the comparison result. Let’s call it “isMatch” and set its default value to False.
  2. Use a “For Each” activity to iterate over each item in List 2.
  3. Inside the loop, place an “Assign” activity to compare each item with List 1. Set the condition using the “Equals” activity. For example, you can compare the current item in List 2 with each item in List 1.Assign activity:

makefileCopy code

isMatch = List1.Contains(currentItem)

Here, List1 represents the first list, and currentItem represents the current item in List 2.
4. If the comparison in step 3 results in a match, set the “isMatch” variable to True using another “Assign” activity.

Hi @rayz1503

 The "SequenceEqual" method compares the elements of two sequences (in this case, lists) and returns True if they have the same elements in the same order. Otherwise, it returns False.

image

The Output returns False

Hi @rayz1503

  1. Assign two List Variables say List1 and List2 of datatype System.Collections.Generic.List(String).
List1= New List(of String) from {"A","B","C","D"}
List2= New List(of String) from {"B","D"}
  1. Use For each loop to iterate through List1
  2. Use an Assign activity and write the below syntax
currentItem=Item.ToString
  1. Use an if activity and write the below condition
List2.Contains(Item)
  1. Use an assign activity and create an variable ItemExists of datatype Boolean.
  2. Use Log message to print the value.

Note: Attached workflow for your reference
Sequence7.xaml (10.1 KB)

Hope it helps!!
Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.