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
    
1 Like

Hi,

Another solution:

Can you try the following condition in IF activity?

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

Regards,

2 Likes

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