Hi, what’s the most efficient method to get a list or array of all the unique values in a column from a DataTable? Preferably without looping, thanks
Filter based on one column -
Filter based on more than one column -
yourDT.DefaultView.ToTable(true, "ColumnName1", "ColumnName2"...."ColumnNameN")
did u get the solution for this?
Yes, it worked @vicky1234567890. Please find the workflow, use this as a function (Plug & Play).
GetDistinctDataTable.xaml (5.5 KB)
Hi Karthik, one correction I believe, it should be true instead of false.
Thanks. You are right.
For distinct values - true.
Thank you for letting me know.
Hi one more question , If I need the datarows as well corresponding to the unique column values, how could that be done?
dt.AsEnumerable().GroupBy(Function(a) a.Field(Of String)(“name”)).Select(Function(b) b.First).CopyToDataTable()
You can use this one as well.
I don’t know why it is not working in my case…can you help, please
I want unique Numbers in sheet2
If I’m doing wrong please correct me.
check.zip (23.0 KB)