How to check all the values in a particular column is similar

Hi ,
I want to check all the values in a particular column is similar,if it is similar it should throw error.
ex:
kkk
kkk
kkk
In the above all values are similar to certain string(kkk), so it should throw error,
If the one value contains different then it should not throw error.

1 Like

@karthik_kulkarni1

  1. Use Read Range activity to read the data from excel file and it will give output as DataTable. Let’s say ‘InputDT’.

  2. And then try below expressions.

       Int UniqueRowCount = InputDT.DefaultView.ToTable(True,"ColumnName").Rows.Count
    
       Int DuplicateRowCount = InputDT.DefaultView.ToTable(False,"ColumnName").Rows.Count
    
    
     If UniqueRowCount = DuplicateRowCount
     Then
          Column does not contain duplicate rows
      Else
          Column contains duplicate rows

Hi,

Another solution:

Can you try the following condition in IF activity?

dt.AsEnumerable.GroupBy(Function(r) r("TargetColumn").ToString).Count=1

Regards,

Hi

Hope the below steps would help you resolve this

  1. Let’s say you have a datatable named dt with the column values
    And the same value lies in Column-2

  2. Use a assign activity like this

int_rowcount = dt.Rows.Count

Where int_rowcount is a variable of type int32

  1. Now use a REMOVE DUPLICATE Rows ACTIVITY where pass input as dt and get the output as dt
  1. Now use a IF activity like this

int_rowcount <= dt.rows.count

If true it has no duplicate records where it goes to THEN block and if false it has duplicate records where it goes to ELSE block

In then block leave it as it is

And in else block use a THROW activity and mention like this

new BusinessRuleException(“Your exception message”)

Cheers @karthik_kulkarni1

1 Like

Thank you all for giving solutions

Happy automation

Do you have any further queries on this topic

@karthik_kulkarni1

No,I dont have

Great

Pls close this topic with right comment marked as solution
@karthik_kulkarni1