cancel
Showing results for 
Search instead for 
Did you mean: 

How to filter collection to have unique values

Anonymous
Not applicable
Hi, I have created a process that collects the country code and name of a people into a collection. But since there are people from the same country, the country codes overlap. I am trying to create a loop that will help me filter the collection so that I am left with just one of each country codes. I tried using the Collection Contains Value action, but either I am doing it incorrectly or it just doesn't seem to work. If anyone has any ideas, it would be of much help. Thanks. Yoon-A
1 REPLY 1

Anonymous
Not applicable
Hi, For filtering collection you could use ""Utility - Collection manipulation"" => ""Filter Collection"" but I think DataTable(BP Collection) does not support Distinct keyword, thus writing ""distinct column1"" in Filter field wouldn't work. I have got two solutions for you. 1st is to use 2 collections. Original Collection that you want to filter and Filtered Collection where you'll put only distinct values. The process could look like: You loop over original collection and check if current value is already in second collection. If it is not, add it to second collection, if it already exists in second collection, omit it and go next. 2nd is to create your own Code Stage for eg. you could use: - Linq - public DataTable ToTable(bool distinct,params string[] columnNames) eg. MyTable.ToTable(true, ""Col1"", ""Col2"") However, here you have to create View of table first and then convert it to Table using ""ToTable"" ;) Hope it helps.