cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop "Filter Collection" from sorting the result by default.

MeghalVasa
Level 3
I have a collection with one column data as below: (Collection In = Lines) |------------------------------------------| Field Name = Line (Text) Name                Microsoft OneDrive for Business Publisher           Microsoft Corporation Status              New Name                McAfee Endpoint Security Web Control Publisher           McAfee, Inc. Status              Enabled Name                Send to OneNote Publisher           Not Available Status              Disabled |------------------------------------------| Now I want to convert this to a (Name|Status) collection, so I first filter the collection by Name & then by Status & then merge the 2 collections to obtain something like below: (This works fine except the entries misalign as they get sorted alphabetically by default within "Filter Collection" stage which is not desired) |-----------------------------------|-------| Name (Text) | Status Text) Microsoft OneDrive for Business  | New McAfee Endpoint Security Web Control | Enabled Send to OneNote | Disabled |-----------------------------------|-------| The Collection manipulation -> Filter Collection stage is giving in snapshot has Collection In as "Lines" above & the Filter is given as "[Line] LIKE '%Name%'" The inbuilt VBO "Filter collection" is by default given the filtered output in a new Collection in a sorted order like below |------------------------------------------| Line (Text) McAfee Endpoint Security Web Control Microsoft OneDrive for Business  Send to OneNote |------------------------------------------| but I need it in the order of Collection In as it is... Unsorted. How do I do it? Why is the "Collection Manipulation" -> "Filter Collection"  VBO Sorting the filtered result alphabetically by default when there is already another action of "Sort Collection" already present in same VBO? Please tell me how to change the default behavior of this VBO to not sort the Output Collection. What changes I can do or which is easiest way to fix this.  
5 REPLIES 5

ManishKumar3
Level 3
you can try by creating custom transpose for collection.  1. Get Original Data into first collection. 2. Identify manually unique rows.. like 3 in above case and row position which is required as in column in another collection (eg. 1 & 3 above) 3. Create new second collection and Loop original collection with counter of rows 4. Use Choice  and Set new collection values as per loop and increase counter value. 5. Reset counter once it reaches max 6. add new row to second collection and it will follow step 4. 7. Remove empty rows (may be last row will be empty) second collection will have data as per your need. Done!

TomCirone
Level 6
You could also a column with the row number (loop over collection with a counter being inputted as the values).  Then you filter the same way, sort by that row number column, and then delete the row number.

AmiBarrett
Level 12

C# code to append an AI/PK column to the collection. I'm pretty sure the PK flag will go away on export, but you can use it internally if you need to. It's a bit hacky, but it'll do the job.

In:
Collection - Collection

Out:
New_Collection - Collection  

DataColumn col = new DataColumn();
col.DataType = System.Type.GetType("System.Int32");
col.ColumnName = "AIid";
col.AutoIncrement = true;
col.AutoIncrementSeed=0;
col.AutoIncrementStep = 1;
Collection.Columns.Add(col);
int index = 0;
foreach(DataRow row in Collection.Rows) 
{
	row["AIid"]=index++;
}
New_Collection = Collection;

VijayDodamani
Level 5
Hello Meghal, You can able to filter the collection on multiple columns with multiple condition, doing so you need not do the 2 filter operation.  After you getting the final collection from the filtered (with multiple column condition), you just need to sort the collection.   Please find an attachment for the same

ChristianLobosc
Level 3
When you use the filter function for a collection results are stored in reverse. Example the first filtered match will appear in the first row and the second match will appear in the first row pushing down the first match to the second row and so fourth. Basically a new row is inserted at the top the collection when a match is found and will store the filtered value. Easiest way to keep everything in the correct order as per the unfiltered collection is to use the Reverse Collection Stage in collection Manipulation. This is the easiest solution I have found to work. Hope this helps.