<?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>Duplicate string in the string array</title><link>https://community.appian.com/discussions/f/rules/12086/duplicate-string-in-the-string-array</link><description>I have an array of strings i need the string which is duplicate . can u give me any simple functions to achieve this. 
 My array would be like this &amp;#123;&amp;quot;one&amp;quot;,&amp;quot;two&amp;quot;,&amp;quot;one&amp;quot;,&amp;quot;three&amp;quot;&amp;#125; 
 Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Duplicate string in the string array</title><link>https://community.appian.com/thread/53578?ContentTypeID=1</link><pubDate>Thu, 22 Mar 2018 14:00:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9372e3a9-6e5b-4b61-a949-9703364e9a54</guid><dc:creator>PhilB</dc:creator><description>As  has said, there&amp;#39;s no one function for this. You might find it useful to refer to the searchable list of functions here: &lt;a href="https://docs.appian.com/suite/help/18.1/Appian_Functions.html"&gt;docs.appian.com/.../Appian_Functions.html&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate string in the string array</title><link>https://community.appian.com/thread/53549?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 18:21:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3a1095da-889e-4b85-91a8-c928749beb1c</guid><dc:creator>Mike Schmitt</dc:creator><description>There is no direct (out-of-box) function for this as far as I&amp;#39;m aware; in the past I&amp;#39;ve implemented this as a global Expression Rule which can receive any array and returns the duplicated members of that array, so that i can have consistency across my system (and not need to type out all that code over and over again).&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate string in the string array</title><link>https://community.appian.com/thread/53545?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 17:53:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6aa58fcc-fd13-49ef-8be8-f080a5777fcb</guid><dc:creator>bhargavip</dc:creator><description>Thanks @Mike and &lt;a href="/members/vimals"&gt;vimalkumars&lt;/a&gt;  your answers gave me what I want. But I was just looking for one function if we have directly so that reduces code.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate string in the string array</title><link>https://community.appian.com/thread/53541?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 17:33:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:231c6d8d-ed50-44eb-a52d-0bd1dbde28a2</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;So far the only solution that correctly addresses your requirement (returning the duplicated value(s), not returning a duplicates-removed array) was the answer submitted by&amp;nbsp;&lt;a href="/members/vimals"&gt;vimalkumars&lt;/a&gt;&amp;nbsp;above.&amp;nbsp;&amp;nbsp;I will provide my version here, slightly cleaner (imho) and removing one error in Vimal&amp;#39;s version.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;with(
  
  /* example array - this can be replaced logically with whatever you need */
  local!items: {&amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;one&amp;quot;, &amp;quot;three&amp;quot;},
  
  local!duplicatesRemoved: union(local!items, local!items), /* in your environment, i suggest implementing a global rule to handle de-duplicating arrays, in case a better solution than &amp;quot;union&amp;quot; is found in the future */
  
  a!forEach(
    items: local!duplicatesRemoved,
    expression: if(
      apn_arraylength(wherecontains(fv!item, local!items)) &amp;gt; 1,
      fv!item,
      /* we need to return an empty set here (instead of &amp;#39;null()&amp;#39;) to avoid returning nulls in the resulting array */
      {}
    )
  )
)&lt;/pre&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Note that the &amp;quot;if&amp;quot; statement needs to return an empty set instead of &amp;quot;null&amp;quot;, or else the resulting array will contain nulls along with the duplicate members, instead of just the duplicate members.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate string in the string array</title><link>https://community.appian.com/thread/53536?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 11:10:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a5a942d6-157b-4d36-ab96-f966a8ca533f</guid><dc:creator>Vinay Kumar Rai</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Use intersection function&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;=load(

  local!StringInput: {&amp;quot;one&amp;quot;,&amp;quot;two&amp;quot;,&amp;quot;one&amp;quot;,&amp;quot;three&amp;quot;},
  
  intersection(local!StringInput,local!StringInput)
  
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate string in the string array</title><link>https://community.appian.com/thread/53533?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 10:33:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:db0d133e-3892-4e23-a843-8a65dfddf9dd</guid><dc:creator>vimalkumars</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="/members/bhargavip"&gt;bhargavip&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Assuming if the array is&amp;nbsp;&amp;nbsp;{&amp;quot;one&amp;quot;,&amp;quot;two&amp;quot;,&amp;quot;one&amp;quot;,&amp;quot;three&amp;quot;} and if you are looking for the duplicate values in this array which is {&amp;quot;one&amp;quot;}.&lt;/p&gt;
&lt;p&gt;You can use the below code for this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;reject(
  fn!isnull,
  a!forEach(
    items: union({&amp;quot;one&amp;quot;,&amp;quot;two&amp;quot;,&amp;quot;one&amp;quot;,&amp;quot;three&amp;quot;},{&amp;quot;one&amp;quot;,&amp;quot;two&amp;quot;,&amp;quot;one&amp;quot;,&amp;quot;three&amp;quot;}),
    expression: if(
      count(
        wherecontains( fv!item, {&amp;quot;one&amp;quot;,&amp;quot;two&amp;quot;,&amp;quot;one&amp;quot;,&amp;quot;three&amp;quot;})) &amp;gt; 1,
        fv!item,
        null
      )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate string in the string array</title><link>https://community.appian.com/thread/53527?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 08:00:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7bdaf1b7-cbc8-4ba6-8761-b6d5016cda41</guid><dc:creator>aloks0189</dc:creator><description>Hi &lt;a href="/members/bhargavip"&gt;bhargavip&lt;/a&gt;  you can use following code to achieve your requirement &lt;br /&gt;
&lt;br /&gt;
union({&amp;quot;a&amp;quot;,&amp;quot;b&amp;quot;,&amp;quot;a&amp;quot;,&amp;quot;c&amp;quot;},{&amp;quot;a&amp;quot;,&amp;quot;b&amp;quot;,&amp;quot;c&amp;quot;,&amp;quot;a&amp;quot;})&lt;br /&gt;
&lt;br /&gt;
Assume {&amp;quot;a&amp;quot;,&amp;quot;b&amp;quot;,&amp;quot;a&amp;quot;,&amp;quot;c&amp;quot;} is the array which is available in a variable&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate string in the string array</title><link>https://community.appian.com/thread/53522?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 06:04:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:062adf6e-66de-42ad-9d3e-e6318cf864bd</guid><dc:creator>Sudha</dc:creator><description>Union() -Remove the duplicates from an array by comparing it with an empty array of the same type:&lt;br /&gt;
&lt;br /&gt;
union({1, 2, 3, 4, 1, 2}, tointeger({})) returns and array with 1, 2, 3, 4&lt;br /&gt;
&lt;br /&gt;
Values are matched with case sensitivity&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate string in the string array</title><link>https://community.appian.com/thread/53521?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 06:01:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:131b96e1-e111-4116-bba3-b3246923c168</guid><dc:creator>Sudha</dc:creator><description>Hi,&lt;br /&gt;
Could you please try the union().&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
Sudha.P&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>