Checking if Data in one Column is contained in another Column

Hi,

I am getting stuck when trying to check if all values from one column are contained in another column.

Ideally if all the values exist, I would like to assign a boolean saying “True”

here is an example of what I am trying to achieve:

If all the values in Column1 are found in Column2 = True:

Column1 Column2
1 1
2 2
3 3
4
5

If at least one value in Column1 is NOT found in Column2 = False:

Column1 Column2
1 1
2 2
3 3
10 4
5

Any ideas?

Hi @Falcao

Please check this LINQ query works for you

dt1.AsEnumerable.where(function(rows) rows(“Column1”).ToString.Equals(rows(“Column2”).ToString)).ToList.Count

You can compare count with datarow count and make decision. Attached xaml for reference

AssignBooleanBasedOnColumnComparison.xaml (8.7 KB)

Thanks,

Hi,

Can you try the following condition?

dt.AsEnumerable.Where(Function(r) r(0) isnot Nothing AndAlso not String.IsNullOrEmpty(r(0).ToString)).All(Function(r) dt.AsEnumerable.Select(Function(r2) r2(1).ToString).Contains(r(0).ToString))

Regards,