cancel
Showing results for 
Search instead for 
Did you mean: 

Remove small collection from bigger collection

Hi.   I have a problem where I Filter out some rows from a collection and I want to remove them from the main collection. How do I best do this?     Extra info: A collection is on 9000. I filter out 100 rows, I want to remove them from the main collection. I will then end up with 8900 rows.   Best regards Christer Tellefsen
2 REPLIES 2

SukeshManthena
Level 4
Hello, Go for using ""Utility - Collection Manipulation"" VBO several Actions available to filter it out. Good Luck.  

AmiBarrett
Level 12

I made a separate action for this - ""Search Collection where value does not contain [x]"". I did this in C#, so you may need to convert it if you want it to work in the regular collection manipulation VBO. Or if you want to make your own extended library (which is generally recommended practice anyway, so new builds don't overwrite your code), I'm also including the references at the top that you'll need to add. Some of these are overkill for just this one action, but it'll get you started for expanding with other actions.

External Refs:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Core.dll Microsoft.VisualBasic.dll Namespace Imports: Microsoft.VisualBasic
System.Collections.Generic
System.Text
System.Linq Microsoft.VisualBasic.FileIO

Inputs:
Collection - Collection
FilterString - Text
Column - Text

Outputs:
Sorted Collection - Collection  

String filter = """"; if(FilterString!="""")
{
	filter = ""`""+Column+""`"" + "" not like '%""+FilterString+""%'""; 
}
else
{
	filter = ""`""+Column+""`"" + "" = ''"";
}
DataView dv = Collection.DefaultView;
dv.RowFilter = filter;
Sorted_Collection = dv.ToTable();