<?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>Finding repeated items in an array</title><link>https://community.appian.com/discussions/f/general/13848/finding-repeated-items-in-an-array</link><description>Hi All, 
 I have an array 1,2,3,3,5,6 
 In this I want the repeated value which is 3 as output. 
 Can you please suggest which is the approach to be followed. 
 TiA 
 Harsha</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Finding repeated items in an array</title><link>https://community.appian.com/thread/62908?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 06:16:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c5f9e2f5-e93f-4778-ac17-37a3d2fe4577</guid><dc:creator>saivineeths</dc:creator><description>Hi Harsha,&lt;br /&gt;
&lt;br /&gt;
   Please find the code snippet.&lt;br /&gt;
&lt;br /&gt;
load(&lt;br /&gt;
  local!a:{1,2,3,3,45,45},&lt;br /&gt;
  local!b:a!forEach(&lt;br /&gt;
    items:local!a,&lt;br /&gt;
  expression:&lt;br /&gt;
  if(count(&lt;br /&gt;
  wherecontains(fv!item,local!a))&amp;gt;1,fv!item,{})&lt;br /&gt;
),&lt;br /&gt;
union(local!b,local!b)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
sai Vineeth&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Finding repeated items in an array</title><link>https://community.appian.com/thread/62904?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 05:41:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:054d19a0-17b6-4fde-839d-5538d9ae1eb8</guid><dc:creator>Abhay Giri</dc:creator><description>Hi,&lt;br /&gt;
&lt;br /&gt;
try below one:&lt;br /&gt;
&lt;br /&gt;
load(&lt;br /&gt;
  local!data: {&lt;br /&gt;
    1,&lt;br /&gt;
    2,&lt;br /&gt;
    3,&lt;br /&gt;
    4,&lt;br /&gt;
    1,&lt;br /&gt;
    2,&lt;br /&gt;
    5,&lt;br /&gt;
    4&lt;br /&gt;
  },&lt;br /&gt;
  local!dupplicateData: a!forEach(&lt;br /&gt;
    items: local!data,&lt;br /&gt;
    expression: if(&lt;br /&gt;
      length(&lt;br /&gt;
        wherecontains(&lt;br /&gt;
          fv!item,&lt;br /&gt;
          local!data&lt;br /&gt;
        )&lt;br /&gt;
      ) &amp;gt;= 2,&lt;br /&gt;
      fv!item,&lt;br /&gt;
      {}&lt;br /&gt;
    )&lt;br /&gt;
  ),&lt;br /&gt;
  union(&lt;br /&gt;
    local!dupplicateData,&lt;br /&gt;
    local!dupplicateData&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
regards&lt;br /&gt;
abhay&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Finding repeated items in an array</title><link>https://community.appian.com/thread/62901?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 03:11:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d073788d-5759-43d1-9644-3f4638a2b337</guid><dc:creator>Hema</dc:creator><description>&lt;p&gt;Hi Harsha,&lt;/p&gt;
&lt;p&gt;The below code snippet would be helpful to you,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;load(
  local!data: {1,2,3,4,3,5,6,5,4,7},
  local!uniqueData: union(
    local!data,
    local!data
  ),
  reject(
    fn!isnull,
    a!forEach(
      items: local!uniqueData,
      expression: if(
        count(
          wherecontains(
            fv!item,
            local!data
          )
        ) &amp;gt; 1,
        fv!item,
        null
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Hema&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Finding repeated items in an array</title><link>https://community.appian.com/thread/62896?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 00:00:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:62034a35-c41b-4429-814f-e3980fbed15c</guid><dc:creator>aloks0189</dc:creator><description>&lt;p&gt;Hi Harsha,&lt;/p&gt;
&lt;p&gt;Please find the code snippet demonstrating one of the approach to achieve your requirement below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;load(
  local!items_int: {1, 2, 3, 3, 4, 5, 4, 6},
  local!res,
  local!content: a!forEach(
    local!items_int,
    if(
      count(wherecontains(fv!item, local!items_int)) &amp;gt; 1,
      append(local!res, fv!item),
      append(local!res, {})
    )
  ),
  union(
    local!content,
    local!content
  )
)

/* OUTPUT:  3, 4  (Type: List of Number (Integer) ) */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hope this will help you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>