LinQ to adquire the unique values in a Column DataTable and create a List With all that Values

Hello I have this input:
image
And the output that I want is:
Array_Names={“Alex”,“Dante”,“Vergil”}

dtData.AsEnumerable().Select(Function (x) x("COLUMN1").toString.trim).Distinct().toArray
1 Like

Hi @Fabio_Villamil

Try this:

=> Read Range Workbook
image
Output-> dt

=> Use Below syntax in Assign:

uniqueNames = dt.AsEnumerable().Select(Function(row) row.Field(Of String)("COLUMN1").Trim()).Where(Function(name) Not String.IsNullOrEmpty(name)).Distinct().ToArray()

uniqueNames is of dataType Array(System.String)

=> You can print it in Message Box or Log Message String.Join(", ", uniqueNames)

Regards

1 Like

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