Displaying list of duplicate records from DataTable

How to find out duplicate records from data table and then displaying the results.
Suppose, we have a list of employees,city and their id. The city column has duplicate records, how to find out duplicate records and then display the results, an easy method, please.

@Surabhi_Basal

Welcome to our UiPath community.

Try below expression to find duplicate records based on City column.

    DuplicateDT = InputDT.DefaultView.ToTable(False,"City")

Hi,

Below code will find the duplicate entries from datatable on specific column then store the results into list.

List_variable = yourdatatablename.AsEnumerable().Select(Function (a) a.Field(of string)(“yourcolumnname”).ToString).ToArray().GroupBy(Function(x) x).Where(Function(y) y.Count() > 1).ToList()

Hi Lakshman,

Thank you for the suggestion, but this is giving me only distinct records not the duplicate ones, for e.g I have list of cities namely Pune, Delhi,Delhi,Delhi,Mumbai and corresponding to this name- A, B,C,D,E, as an output I want Delhi to be printed (since it is occuring thrice and is duplicate) and its corresponding name.

1 Like

Thanks Lakshman, by using False,its printing all the records.

@Surabhi_Basal

Can you please try above expression provided by @ghazanfar