How to filter datatable from linq query

Hi,

I have a datatable with LastName, FirstName, UserName. Want to extract all duplicate UserNames which has Different last name and First Name. (Only with co-related duplicates like below expected results.)

image

Expected Results Should be:
image

Even Carter, Follett are also repeated, why those are not their in expected result image? @Gopikrishna

@Manish540 I need only co-related duplicates only like expected results.

Can you send a sample excel file, with those values? @Gopikrishna

Sample.xlsx (23.9 KB)

Try this:


For Each properties:
image

Edit: maybe you need to tweak it or expand on it to make it complete for you.

@atomic I have for each solution already. Am delaying with more than 100k records.
So, specifically looking for link query.

LINQ query in UiPath | Compact your code with the help of LINQ query - YouTube

Check this below workflow, @Gopikrishna
Uipath_FilterDataTableByLinq.xaml (7.9 KB) and also find the output file Out12.xlsx (10.9 KB)
Hope this may help you :slight_smile:

@Manish540 Thanks for your attempt. But I what I need is only duplicate which has different last name and first name
expected output:

Last Name First Name Username
Williams Nicole 9184134842
Williams Nicole 9184134842
Williams Nicolea 9184134842

Your output:

Last Name First Name Username
Williams Nicole 9184134842
Williams Nicole 9184134842
Williams Nicolea 9184134842
Williams Juandasia 2255724457
Williams Juandasia 2255724457
Williams Brittany 6624523142
Williams Deonne 4199847132
Williams Deonne 4199847132
Williams Barry 4054652447
Williams Keren 2038592938
Williams Keren 2038592938

Hi @Gopikrishna

Please take a look at the below Xaml.

dataSequence.xaml (7.3 KB)

This is what you need i am right!

Thanks

@Gopikrishna

give a try on following LINQ

(From d in dtData.AsEnumerable
Group d by k=d("Username").toString into grp=Group
let check = grp.Select(Function (x) x("Last_Name").toString.Trim & x("First_Name").toString.Trim).Distinct().Count
Where check > 1
Select grp.toList).SelectMany(Function (s) s).CopyToDataTable

We can assume that also an empty result will be returned. So apply following pattern for handling this as well:

1 Like

@ppr Many thanks. Working as expected.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.