How to filter n rows in a collection
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-06-20 12:43 PM
I have a collection which is a final collection after using sort collection. From that final collection, I want to filter only "n' rows for example only Top 3 from that collection.
So my final output collection should look like
1. Suman3 - 52.3
2. Suman4 - 42.2
3. Suman - 40.99
Could someone please help me on this?
------------------------------
Chanda Suman
Sr. Automation Specialist II
S&P Global
Asia/Kolkata
------------------------------
So my final output collection should look like
1. Suman3 - 52.3
2. Suman4 - 42.2
3. Suman - 40.99
Could someone please help me on this?
------------------------------
Chanda Suman
Sr. Automation Specialist II
S&P Global
Asia/Kolkata
------------------------------
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-06-20 01:14 PM
Hi Suman,
I just need to know on what criteria you are going to filter for 'n' rows from final collection which is sorted? or
just need only 'n' rows from top of collection without any filter specification?
Regards,
------------------------------
Yeswa Vaibhav Alwar Nerella
Associate Consultant
Capgemini
Asia/Kolkata
------------------------------
I just need to know on what criteria you are going to filter for 'n' rows from final collection which is sorted? or
just need only 'n' rows from top of collection without any filter specification?
Regards,
------------------------------
Yeswa Vaibhav Alwar Nerella
Associate Consultant
Capgemini
Asia/Kolkata
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-06-20 02:57 PM
Hi Vaibhav,
Thanks for the reply. I won't have any filter specifications.
In your words. I require "just need only 'n' rows from top of collection without any filter specification?"
------------------------------
Chanda Suman
Sr. Automation Specialist II
S&P Global
Asia/Kolkata
------------------------------
Thanks for the reply. I won't have any filter specifications.
In your words. I require "just need only 'n' rows from top of collection without any filter specification?"
------------------------------
Chanda Suman
Sr. Automation Specialist II
S&P Global
Asia/Kolkata
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-06-20 03:07 PM
In that case you can copy those number of rows to another collection, by using copy rows action stage in Collection Manipulation VBO. Add as many rows you need. Refer screenshot.
Let me know if it is not clear. It will work.
Regards,
------------------------------
Yeswa Vaibhav Alwar Nerella
Associate Consultant
Capgemini
Asia/Kolkata
------------------------------
Let me know if it is not clear. It will work.
Regards,
------------------------------
Yeswa Vaibhav Alwar Nerella
Associate Consultant
Capgemini
Asia/Kolkata
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-06-20 03:34 PM
Thanks Vaibhav... This definitely helps and will use this one for sure.
Anything we could do using "Filter Collection" under Utility collection manipulation?
------------------------------
Chanda Suman
Sr. Automation Specialist II
S&P Global
Asia/Kolkata
------------------------------
Anything we could do using "Filter Collection" under Utility collection manipulation?
------------------------------
Chanda Suman
Sr. Automation Specialist II
S&P Global
Asia/Kolkata
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-06-20 04:46 PM
The code stage within "Filter Collection" currently only uses the DataTable.Select() method, which does not support this. However, you could make a clone of this action and supply an input for number of rows you need. This will also require some changes to the object dependencies, which I'll list below.
In code options, add to External References:
System.Data.DataSetExtensions.dll
System.Core.dll
In code options, add to External References:
System.Linq (It boggles my mind that this isn't in here to begin with, but that's neither here nor there.)
Add input:
number - Number (Specifies number of top rows to pull)
Change line 3 to:
Add to ln 13:
Edited to take top rows post-filter instead of pre-filter
------------------------------
Ami Barrett
Sr Product Consultant
Blue Prism
Plano, TX
------------------------------
In code options, add to External References:
System.Data.DataSetExtensions.dll
System.Core.dll
In code options, add to External References:
System.Linq (It boggles my mind that this isn't in here to begin with, but that's neither here nor there.)
Add input:
number - Number (Specifies number of top rows to pull)
Change line 3 to:
Add to ln 13:
Collection_Out = Collection_Out.AsEnumerable().Take(number).CopyToDataTable()
Edited to take top rows post-filter instead of pre-filter
------------------------------
Ami Barrett
Sr Product Consultant
Blue Prism
Plano, TX
------------------------------