DATATABLE FILTER WITH RESPECT TO SINGLE COLUMN AND GET ALL COLUMNS IN RESULTING DATATABLE?

Hi Team,

I need to find the unique data from city and filter the datatable with respect to the City and finally get all the columns of that data.

Input Datatable:- (dtSample)

Name City
Alex Mumbai
John Chennai
Abc Mumbai
Xyz Pune
pqr Pune
Ron Mumbai

Output Datatable:- (dtFinal)

Name City
Alex Mumbai
John Chennai
Xyz Pune

Please help. It is urgent.

Thanks and Regards,
@hacky

@Dominic, @arivu96, @KarthikByggari, @Karthick_Settu
Your help for approaches and logic matters alot.

Kindly give me few minutes for this.

Thanks and Regards,
@hacky

@hacky

Try below expression and will get required output as you mentioned in above post:

dtFinal = dtSample.Defaultview.Totable(true,“Name”,“City”).CopyToDataTable

@lakshman,

Thanks for your reply.

But as I have already tried your expression, I got the result which was unique with respect to Name and City both.

But what I want was the result which was unique only with respect to City

If you want only city just change the expression given by lakshman to the following -

dtFinal = dtSample.Defaultview.Totable(true,“City”).CopyToDataTable

1 Like

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