<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Count unique values in a collection in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99107#M46729</link>
    <description>&lt;P&gt;&lt;A class="user-content-mention" data-sign="@" data-contactkey="d81bd6aa-b63d-4b90-8a38-018d63f1ebc1" data-tag-text="@Samuel Yeung" href="https://community.blueprism.com/network/profile?UserKey=d81bd6aa-b63d-4b90-8a38-018d63f1ebc1" data-itemmentionkey="7bc8f659-70b1-4760-aab2-8962b11e9577"&gt;@Samuel Yeung&lt;/A&gt; i thought about this again and realised that it might actually be useful to have an action that counts the number of instances of a specific value in the a specified column so I create a new action in the Utility - Collection Manipulation Extended if its useful to you?&lt;/P&gt;
&lt;P&gt;The code is simple so you can just copy and paste it, in the Collection Manipulation vbo just duplicate the action 'Filter Collection' and then rename the new action to Count Occurrences. In the code stage delete the existing code and replace it with the following:&lt;/P&gt;
&lt;DIV&gt;Dim count As Integer&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;For Each parentRow As DataRow In Collection_In.Select(Select_Condition)&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; count += 1&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Next&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;CountOccurrences = count&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Then just delete the output collection and create a new output data item called Count. Since its based on the filter collection action you can just the inputs as they are and to count the collection your input parameters would be the collection and then the count criteria as "[columnname]='ValuetoCount'"&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36047.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36062iE02E3AC2DAAC86DD/image-size/large?v=v2&amp;amp;px=999" role="button" title="36047.png" alt="36047.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36048.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36059i8E7A35D5E12D7F5A/image-size/large?v=v2&amp;amp;px=999" role="button" title="36048.png" alt="36048.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Feb 2024 10:31:18 GMT</pubDate>
    <dc:creator>michaeloneil</dc:creator>
    <dc:date>2024-02-19T10:31:18Z</dc:date>
    <item>
      <title>Count unique values in a collection</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99102#M46724</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;
&lt;P&gt;After retrieving data from a website, I have a collection with some main fields, each having its own sub-fields. The sub-fields will only contain either 'SUCCESS' or 'FAIL'. I want to count the number of results and store them in two seperate data items.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36049.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36057i8363DC162A0500BB/image-size/large?v=v2&amp;amp;px=999" role="button" title="36049.png" alt="36049.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36050.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36060i606965C39B17CAD2/image-size/large?v=v2&amp;amp;px=999" role="button" title="36050.png" alt="36050.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;i.e. Assume there are two main fields, each with 3 sub-fields, after the data collection, 5x SUCCESS and 1x FAIL is recorded. The current value of the SUCCESS should become 5&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36051.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36058iF59F5B0F0E1AB09E/image-size/large?v=v2&amp;amp;px=999" role="button" title="36051.png" alt="36051.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 06:34:50 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99102#M46724</guid>
      <dc:creator>SamuelYeung</dc:creator>
      <dc:date>2024-02-16T06:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values in a collection</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99103#M46725</link>
      <description>&lt;P&gt;Assuming the collections are not gigantic, I would just use a nested loop to work though the child collections, counting each success.&amp;nbsp;Alternatively apply a filter to the child collections and count the resulting rows.&lt;/P&gt;
&lt;P&gt;A more advanced option could be to convert the collection to JSON. Then devise a code stage to deserialize the string into a JSON object that you can then manipulate. The effort to do this probably isn't worth it though.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 10:12:22 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99103#M46725</guid>
      <dc:creator>John__Carter</dc:creator>
      <dc:date>2024-02-16T10:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values in a collection</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99104#M46726</link>
      <description>&lt;P&gt;There isnt an action that counts the values in the collection but you can get the count where you know the value of what you want to count. As John Carter mentioned if its low numbers in the collection then simply loop and count but if you are getting high volumes then you can filter the 'success' values and the 'fail' values into their own collections and then count the number of rows in each. Use the VBO Utility - Collection Manipulation Extended and the action Filter collection, you set the collection you want to filter and the value of the column you want to filter by and the output collection. The next thing is to use the Internal Business Objects, Collections VBO and the action Count rows. You can then count the rows of the filtered collection, screenshots below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36044.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36054i2661E7BBC8E8C7B0/image-size/large?v=v2&amp;amp;px=999" role="button" title="36044.png" alt="36044.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36045.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36056i89678EB893A527CC/image-size/large?v=v2&amp;amp;px=999" role="button" title="36045.png" alt="36045.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36046.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36063i5AEB3E010041984C/image-size/large?v=v2&amp;amp;px=999" role="button" title="36046.png" alt="36046.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 11:36:13 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99104#M46726</guid>
      <dc:creator>michaeloneil</dc:creator>
      <dc:date>2024-02-16T11:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values in a collection</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99105#M46727</link>
      <description>&lt;P&gt;&lt;A class="user-content-mention" data-sign="@" data-contactkey="d81bd6aa-b63d-4b90-8a38-018d63f1ebc1" data-tag-text="@Samuel Yeung" href="https://community.blueprism.com/network/profile?UserKey=d81bd6aa-b63d-4b90-8a38-018d63f1ebc1" data-itemmentionkey="f77f29ae-3c47-45b5-be4b-ad1d9a9d005e"&gt;@Samuel Yeung&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Playing a little bit upon what&amp;nbsp;&lt;A class="user-content-mention" data-sign="@" data-contactkey="bf6edb31-c42f-4040-9e4b-d47f91046c5a" data-tag-text="@John Carter" href="https://community.blueprism.com/network/profile?UserKey=bf6edb31-c42f-4040-9e4b-d47f91046c5a" data-itemmentionkey="7cd8fedd-f7af-40c8-9b11-0bde822a570c"&gt;@John Carter&lt;/A&gt; had suggested, you could use the "Collection To JSON" action in "Utility - JSON" to convert the collection to Text.&amp;nbsp;Then, if you have a count occurrences action, you could count the occurrences of "FAIL" and "SUCCESS" (including the double quotes). If you do not have a count occurrences action, you could use the "Extract Regex All Matches" action in BP's "Utility - Strings" VBO on each of "FAIL" and "SUCCESS" (including the double quotes) and count the rows in each of the collections.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 14:04:22 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99105#M46727</guid>
      <dc:creator>MichealCharron</dc:creator>
      <dc:date>2024-02-16T14:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values in a collection</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99106#M46728</link>
      <description>&lt;P&gt;@&lt;A href="https://community.blueprism.com/network/profile?UserKey=bf6edb31-c42f-4040-9e4b-d47f91046c5a" target="" class="author" aria-label="John Carter Press space to toggle pop up" aria-haspopup="dialog" aria-controls="bio-bubble-popup-bf6edb31-c42f-4040-9e4b-d47f91046c5a-5"&gt;John Carter&lt;/A&gt; @&lt;A href="https://community.blueprism.com/network/profile?UserKey=ddd4d6a3-af39-4c64-8db4-cdb1d05ed669" target="" class="author" aria-label="Michael ONeil Press space to toggle pop up" aria-haspopup="dialog" aria-controls="bio-bubble-popup-ddd4d6a3-af39-4c64-8db4-cdb1d05ed669-7"&gt;Michael ONeil&lt;/A&gt; @&lt;A href="https://community.blueprism.com/network/profile?UserKey=3984407d-fe7b-42fc-9b76-57d2a70c9678" target="" class="author" aria-label="Micheal Charron Press space to toggle pop up" aria-haspopup="dialog" aria-controls="bio-bubble-popup-3984407d-fe7b-42fc-9b76-57d2a70c9678-9"&gt;Micheal Charron&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thanks for the answers!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 01:00:47 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99106#M46728</guid>
      <dc:creator>SamuelYeung</dc:creator>
      <dc:date>2024-02-19T01:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique values in a collection</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99107#M46729</link>
      <description>&lt;P&gt;&lt;A class="user-content-mention" data-sign="@" data-contactkey="d81bd6aa-b63d-4b90-8a38-018d63f1ebc1" data-tag-text="@Samuel Yeung" href="https://community.blueprism.com/network/profile?UserKey=d81bd6aa-b63d-4b90-8a38-018d63f1ebc1" data-itemmentionkey="7bc8f659-70b1-4760-aab2-8962b11e9577"&gt;@Samuel Yeung&lt;/A&gt; i thought about this again and realised that it might actually be useful to have an action that counts the number of instances of a specific value in the a specified column so I create a new action in the Utility - Collection Manipulation Extended if its useful to you?&lt;/P&gt;
&lt;P&gt;The code is simple so you can just copy and paste it, in the Collection Manipulation vbo just duplicate the action 'Filter Collection' and then rename the new action to Count Occurrences. In the code stage delete the existing code and replace it with the following:&lt;/P&gt;
&lt;DIV&gt;Dim count As Integer&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;For Each parentRow As DataRow In Collection_In.Select(Select_Condition)&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; count += 1&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Next&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;CountOccurrences = count&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Then just delete the output collection and create a new output data item called Count. Since its based on the filter collection action you can just the inputs as they are and to count the collection your input parameters would be the collection and then the count criteria as "[columnname]='ValuetoCount'"&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36047.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36062iE02E3AC2DAAC86DD/image-size/large?v=v2&amp;amp;px=999" role="button" title="36047.png" alt="36047.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36048.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36059i8E7A35D5E12D7F5A/image-size/large?v=v2&amp;amp;px=999" role="button" title="36048.png" alt="36048.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 10:31:18 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Count-unique-values-in-a-collection/m-p/99107#M46729</guid>
      <dc:creator>michaeloneil</dc:creator>
      <dc:date>2024-02-19T10:31:18Z</dc:date>
    </item>
  </channel>
</rss>

