I need to remove duplicate from data table based on filter.
For example in the below image, 124 is duplicated in ClaimNumber column but subject is different. If there is duplicate, i want to compare with subject column and keep the required rows. Could anyone suggest a linq for this.?
Removing Duplicates.xaml (8.3 KB)
Hi @balaji.murali ,
Please find the attached xaml file. I have builded the query as per your requirment. Pleasea try to use the xaml file and let me know is this working or not?
Thank You!
Welcome to UiPath Forum @balaji.murali
What about this Linq
Input
Output
Workflow
Code
(From row In dt.DefaultView.ToTable(True,"ClaimNumber").AsEnumerable Let r = If(dt.Select("Convert(ClaimNumber,System.String)='"+row("ClaimNumber").ToString+"'").Count>1, If(dt.Select("Convert(ClaimNumber, System.String)='"+row("ClaimNumber").ToString+"' and Convert(subject, System.String)='"+reqSubject+"'").Count>0, dt.Select("Convert(ClaimNumber, System.String)='"+row("ClaimNumber").ToString+"' and Convert(subject, System.String)='"+reqSubject+"'").CopyToDataTable.Rows(0).ItemArray, dt.Select("Convert(ClaimNumber,System.String)='"+row("ClaimNumber").ToString+"'").CopyToDataTable.Rows(0).ItemArray), dt.Select("Convert(ClaimNumber,System.String)='"+row("ClaimNumber").ToString+"'").CopyToDataTable.Rows(0).ItemArray) Select dt2.Clone.Rows.Add(r.ToArray)).copytodatatable
Xaml
Sequence4.xaml (9.7 KB)
reqSubject = YourRequiredValue
Thanks,
Hi @RajKumar_DC
Thanks for the solution. It is working as expected.
I have multiple subjects to filter. How to add that?
Hi @balaji.murali,
just add your condition like below i have add one more column “NewColumn”
Select("Convert(ClaimNumber, System.String)='"+row("ClaimNumber").ToString+"' and Convert(subject, System.String)='"+reqSubject+"' and Convert(NewColumn, System.String)='"+reqSubject+"' ").CopyToDataTable.Rows(0).ItemArray
I need to check like this…
subject =‘aaa’ or subject =‘abc’
Hi @balaji.murali ,
so use “or” Condition
dt.Select("Convert(ClaimNumber, System.String)='"+row("ClaimNumber").ToString+"' and Convert(subject, System.String)='"+reqSubject+"'
or Convert(subject, System.String)='"+"bbb"+"'")
(From row In dt.DefaultView.ToTable(True,"ClaimNumber").AsEnumerable Let r = If(dt.Select("Convert(ClaimNumber,System.String)='"+row("ClaimNumber").ToString+"'").Count>1, If(dt.Select("Convert(ClaimNumber, System.String)='"+row("ClaimNumber").ToString+"' and Convert(subject, System.String)='"+reqSubject+"' or Convert(subject, System.String)='"+"bbb"+"'").Count>0, dt.Select("Convert(ClaimNumber, System.String)='"+row("ClaimNumber").ToString+"' and Convert(subject, System.String)='"+reqSubject+"'").CopyToDataTable.Rows(0).ItemArray, dt.Select("Convert(ClaimNumber,System.String)='"+row("ClaimNumber").ToString+"'").CopyToDataTable.Rows(0).ItemArray), dt.Select("Convert(ClaimNumber,System.String)='"+row("ClaimNumber").ToString+"'").CopyToDataTable.Rows(0).ItemArray) Select dt2.Clone.Rows.Add(r.ToArray)).copytodatatable
Thanks,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.