I have a data table with Names and Id’s I need add two rows that shows weather the name or Id have been used elsewhere in the data table and I need it to be efficient because I have around 3,000 rows. I tried this and UI path crashed.
(From in_row1 In dt.asEnumerable
Let name_arr = (From in_row2 In PTD_DT_out.asEnumerable
Where (in_row2(“First Name”).Equals(in_row1(“First Name”)) And (in_row2(“Last Name”)).Equals(in_row1(“Last Name”))) Select in_row2(“Last Name”)).ToArray
Let Dup_name = If((name_arr.count)>1,True,False)
Let ID_arr = (From in_row2 In PTD_DT_out.asEnumerable
Where in_row2(“Login ID”).Equals(in_row1(“Login ID”)) Select in_row2(“Login ID”)).ToArray
Let Dup_login = If((ID_arr.count)>1,True,False)
Let ra = New Object(){
in_row1(“First Name”),
in_row1(“Last Name”),
in_row1(“Login ID”),
Dup_name,
Dup_login}
Select nr= dt_temp.rows.add(ra)).CopyToDatatable
I apologize for the bad data entry. I think it’s fixed. to further enplane the logic if there is any other row with the same first and last name dub name should be true and if there is any other row with the same ID dup ID should be true.
As we would need the Duplicate Count of Name and ID and it is to be identified exclusively within the Data. We can find the Names which are duplicates separately into a list and the duplicate IDs into a Separate List.
Here, DT is the input data from Excel sheet read using Read Range activity and DupNames is a variable of type Array of String which will contain all the duplicate names present.
DupIds is a variable of type Array of String and will contain the duplicate ID values.
Next we update the Datatable columns based on these findings using the below Expression :
DT = (From r In DT.AsEnumerable
Let IsDupName = DupNames.Contains(r("First Name").ToString+r("Last Name").ToString)
Let IsDupId = DupIds.Contains(r("ID").ToString)
Select DT.Clone.Rows.Add(r.ItemArray.Take(r.ItemArray.Count-2).ToArray.Concat({IsDupName.ToString,IsDupId.ToString}).ToArray)).CopyToDataTable
Let us know if you were not able to follow the above approach.