<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/discussions/f/rules/4635/i-have-an-array-1-2-3-4-4-5-3-i-want-to-know-how-many-duplicate-values-are-t</link><description>I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are there in that Array and the output should return the unique duplicate values like {3,4}. Is there a function to gets this output? OriginalPostID-144331 OriginalPostID-1443</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/67138?ContentTypeID=1</link><pubDate>Fri, 07 Jun 2019 09:49:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:148a0afd-e919-4a60-9fa0-95d43499f552</guid><dc:creator>NicolasY</dc:creator><description>&lt;p&gt;Trie this 100%sure this will wok for you&lt;/p&gt;
&lt;p&gt;union(intersection(ri!array1,ri!array2),intersection(ri!array1,ri!array2))&lt;/p&gt;
&lt;p&gt;greetings&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/65684?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 19:56:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:decc6af7-cad9-4185-9e0d-8a47bb956148</guid><dc:creator>Josh</dc:creator><description>&lt;p&gt; See you in 18 months for another thread revival.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/65683?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 19:54:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:52ae1eb1-819e-4b8c-84bc-22a660cef779</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;fair enough - though if anyone is concerned with using sort() as in my example, they may simply replace this with their own expression rule that sorts via officially supported functionality, i.e. passing an array through toDataSubset with a sorting parameter added.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/65680?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 19:33:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:df0c7a7e-0979-493c-9e7f-bc50288665d7</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;Yes he does specify unique.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/65679?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 19:31:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a1f45cf4-122b-44d2-85b1-a3f3a8b0ff14</guid><dc:creator>Josh</dc:creator><description>&lt;p&gt;It is not correct based on the example provided in the original question. I&amp;#39;m glad it helped you out, though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/65678?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 19:29:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8f31e747-e865-441d-ba69-786d97f5fb09</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;It&amp;#39;s correct from a certain perspective.&amp;nbsp; This preserves the number of times an item has been duplicated.&amp;nbsp; It&amp;#39;s actually exactly what I was looking for.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/65675?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 19:14:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e4f5fa3d-0be4-4ae7-8724-6b973ca7937f</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;I do apologize, but for the sake of others I have to call out my alarm at a suggested answer which features the undocumented sort() function.&amp;nbsp; (I don&amp;#39;t understand why such a thing wouldn&amp;#39;t be documented, but there you go)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/53963?ContentTypeID=1</link><pubDate>Fri, 06 Apr 2018 15:28:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:698ee04e-bc00-48bb-928c-1bd00c4c1926</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Not that this thread isn&amp;#39;t already ancient, but since it&amp;#39;s been brought back up, I&amp;#39;ll post the updated version of my old function that gets duplicate array members (now we have a!forEach and don&amp;#39;t require sub-functions).&lt;/p&gt;
&lt;p&gt;Note: this funciton returns ALL duplicate members, i.e. any and all array members that have a duplicate anywhere else in the array.&amp;nbsp; If the need is for a list where each duplicate member appears only once, this result can be further de-duplicated.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;with(
  local!uniqueMembers: rule!GLBL_removeDuplicateArrayMembers(
    array: ri!array
  ),  /* note: this funciton does &amp;quot;union(ri!array, ri!array)&amp;quot;. it&amp;#39;s useful to have as a global function. */
  
  local!indicesIfMultiple: a!forEach(
    items: local!uniqueMembers,
    expression: with(
      local!indices: wherecontains(
        fv!item,
        ri!array
      ),
      if(
        rule!APN_arrayLength(local!indices) &amp;gt; 1,
        local!indices,
        {}
      )
    )
  ),
  
  index(
    ri!array,
    sort(local!indicesIfMultiple),
    {}
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/53958?ContentTypeID=1</link><pubDate>Fri, 06 Apr 2018 14:28:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7e2779fc-2af1-445e-9256-efb588f73f4a</guid><dc:creator>Josh</dc:creator><description>This is an incorrect solution. It will break for the following case: {1,2,3,4,4,5,5,5,3}. Instead of returning {3,4,5}, it returns {3,4,5,5}.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/53957?ContentTypeID=1</link><pubDate>Fri, 06 Apr 2018 14:17:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c3c1395e-61fb-402b-987e-198a46ba0acc</guid><dc:creator>Thenmozhi Mohanakrishnan</dc:creator><description>load(&lt;br /&gt;
  local!a: {1,2,3,4,4,5,3},  &lt;br /&gt;
  remove(local!a,a!forEach(&lt;br /&gt;
    items: union(local!a,local!a),&lt;br /&gt;
    expression: wherecontains(fv!item,local!a)[1]&lt;br /&gt;
  ))&lt;br /&gt;
)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/16798?ContentTypeID=1</link><pubDate>Wed, 08 Apr 2015 00:13:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d86dd0be-baa8-44f4-b730-ab566bf3f165</guid><dc:creator>Mike Schmitt</dc:creator><description>I&amp;#39;ll throw in the solution I implemented for my project, which will take an Any Type array and return just the duplicates:&lt;br /&gt;&lt;br /&gt;function: getArrayDuplicates()&lt;br /&gt;rule input: ri!array (Any Type)&lt;br /&gt;&lt;br /&gt;with(  &lt;br /&gt;  uniques: union(ri!array, ri!array),&lt;br /&gt;  singlesIndex: if(length(ri!array) = length(uniques),&lt;br /&gt;    {},  &lt;br /&gt;    apply(rule!whereContainsSingle, uniques, ri!array)&lt;br /&gt;  ),  &lt;br /&gt;&lt;br /&gt;  if(length(ri!array) = length(uniques),&lt;br /&gt;    {},&lt;br /&gt;    remove(&lt;br /&gt;      ri!array,&lt;br /&gt;      singlesIndex&lt;br /&gt;    )&lt;br /&gt;  )&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;sub function: whereContainsSingle()&lt;br /&gt;ri!values (any type)&lt;br /&gt;ri!array (any type)&lt;br /&gt;&lt;br /&gt;with(&lt;br /&gt;  indices: wherecontains(ri!values, ri!array),  &lt;br /&gt;  if(length(indices) &amp;gt; 1, {}, indices)&lt;br /&gt;)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/16793?ContentTypeID=1</link><pubDate>Tue, 07 Apr 2015 22:21:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:80b7996f-904c-45e4-a762-f7eee5300ad3</guid><dc:creator>darbyk</dc:creator><description>Hi Fariaj,  if I understand your use case, you want to find and return the duplicate items in your array (e.g. findDuplicates({1,2,3,4,4,5,3, 3}) will return {3,4}.  This is a quick way to do it I believe (keep in mind you&amp;#39;ll probably need some null checks):&lt;br /&gt;&lt;br /&gt;TEST_isDuplicate:&lt;br /&gt;=length(wherecontains(ri!value, ri!array)) &amp;gt; 1&lt;br /&gt;&lt;br /&gt;Then the actual rule - TEST_findDuplicates:&lt;br /&gt;=with(&lt;br /&gt;  local!input: {1,2,3,4,4,5,3},&lt;br /&gt;  local!uniqueInputs: union(local!input, local!input),&lt;br /&gt;  filter(rule!TEST_isDuplicate(_, local!input), local!uniqueInputs)&lt;br /&gt;)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/16774?ContentTypeID=1</link><pubDate>Tue, 07 Apr 2015 19:23:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fdcc5ece-081f-4f27-abae-2036bdabe01c</guid><dc:creator>PhilB</dc:creator><description>I would suggest doing it this way:&lt;br /&gt;&lt;br /&gt;load(&lt;br /&gt;  local!array: {1,2,3,4,4,5,3},&lt;br /&gt;  union(local!array,local!array)&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;You can also use rule!APN_distinct in place of the union() function if you have the common objects installed. If you want to know how many duplicate items there are, just do something like this:&lt;br /&gt;&lt;br /&gt;load(&lt;br /&gt;  local!array: {1,2,3,4,4,5,3},&lt;br /&gt;  length(&lt;br /&gt;    local!array&lt;br /&gt;  ) - length(&lt;br /&gt;    union(&lt;br /&gt;      local!array,&lt;br /&gt;      local!array&lt;br /&gt;    )&lt;br /&gt;  )&lt;br /&gt;)&lt;br /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t</title><link>https://community.appian.com/thread/16770?ContentTypeID=1</link><pubDate>Tue, 07 Apr 2015 17:57:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0cd917b8-2fcd-4c9e-8f3b-6f03ef8ae015</guid><dc:creator>best</dc:creator><description>Use&lt;br /&gt;union({1,2,3,4,4,5,3},tointeger({}))&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>