Get distinct Values from a Data table

Hi,
I have a table which has duplicate values in it. I want to get distinct values from it.
I used the below function.
DatatableName.DefaultValue.Totable(True,Column1,Column2,Column3,Column4)
This gives me Unique value corresponding to the 4 columns mentioned above.
But I want to get Unique Value based on Column1 only. And I just need the other 3 columns as a part of my datatable.
If I give DatatableName.DefaultValue.Totable(True,Column1). the Output datatable contains only 1 column. But I need all the 4 columns.

How can I achieve it?

Thanks in advance

this will give distinct column1 values as a list

DatatableName.AsEnumerable.Select(function(row) row.Field(of String)("Column1")).ToList.Distinct

This gives me unique values of Column1. But I want Column2,3 and 4 as a part of my Output. How can I get that?

Hi @jack.chan,

This code will delete the duplicate value and get the first match.

Please try this.

dtVar.AsEnumerable().GroupBy(Function(x) x.Field(of String)(“ColumnName”)).Select(Function(y) y.First()).CopyToDataTable

Regards
Ömer