Check if repeat value in same column?

Hi all,

If i have this DT :

A
1
2
2
3
4
5

how do I achieve =
for each row in DT, if row.item(“A”) is duplicated then =

Basically, in my example, i want it to acknowledge that the value of “2” is found elsewhere.

Thanks in advance,

Zak

1 Like

Hi @Zak_Cooper

Inside a For Each Row activity use an IF statement with this condition:
image

It returns true if Column “A” contains more than 1 match for item from current row.

3 Likes

Another way is with LINQ by taking the items as a list and using .Distinct with .Count to compare.

For example,

dt1.AsEnumerable.Select(Function(x) x("A").ToString.Trim).Distinct.Count <> dt1.Rows.Count

Using that method, you don’t need to loop through every item.

EDIT: oops
if you only want to compare one item, then you need to use a Loop similar to @loginerror’s solution.

Regards.

1 Like