<?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>Having trouble removing duplicates from an array</title><link>https://community.appian.com/discussions/f/rules/3294/having-trouble-removing-duplicates-from-an-array</link><description>I am trying to remove duplicates from an array. I am trying to use the union() function to find the unique names in an array and then get the rest of the information for those unique names into the array. For the union() it only returns the unique names</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/39675?ContentTypeID=1</link><pubDate>Fri, 25 Nov 2016 09:58:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:98334dc2-824d-4a50-8b48-e8cf62c17357</guid><dc:creator>Ravi</dc:creator><description>Hi lesliec, how did you resolve this issue ?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11600?ContentTypeID=1</link><pubDate>Tue, 26 Aug 2014 19:16:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:aa288a67-3055-4f80-ae3c-672c21616bbf</guid><dc:creator>lesliem</dc:creator><description>Thanks Mike that fixed my process.  I can now select the first item in the array for the wherecontains.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11519?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 18:06:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f91aa383-46f0-4dad-8608-07c502388122</guid><dc:creator>Mike Cichy</dc:creator><description>Wrap the wherecontains() in index().&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11518?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 17:41:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7b65b831-386b-4afd-9174-b09765b35d37</guid><dc:creator>lesliem</dc:creator><description>Thanks Mike that&amp;#39;s what I&amp;#39;ve been trying to do but can&amp;#39;t figure out how to select index 1 with the wherecontains().  ri!oldCDT[wherecontains(ri!name,ri!oldCDT.name)].address) gives me the 2 addresses for the duplicate name.  How do I select index 1?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11490?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 01:21:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dcdd2cd1-27eb-4fee-bbf3-edc244a19289</guid><dc:creator>Mike Cichy</dc:creator><description>First you need an array of unique names - make sure you save into a an array of strings. Then you should iterate over wherecontains for each unique name and select index 1 from each result. Not sure if wherecontains() returns indexes in order, so you will have to verify that manually.&lt;br /&gt;You should be able to do all that within a single with()&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11489?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 01:12:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bfeeb9a7-2a58-46fd-ad69-e826d627c8b3</guid><dc:creator>lesliem</dc:creator><description>I want to keep the first one, no matter what.  The cdt is being created from an Excel Spreadsheet import so I want to take only the first record in the excel spreadsheet for that name.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11488?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 01:11:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8b59e1d5-3fe3-449d-9f77-824a0d0d8c82</guid><dc:creator>Mike Cichy</dc:creator><description>But if the address is different then the entry in the CDT array is not a duplicate. If items have the same names, how do you decide which one to keep?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11485?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 01:05:35 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c69083c0-ed22-4810-b961-5c7a5b5bdce8</guid><dc:creator>lesliem</dc:creator><description>But if say the address on the second record of the duplicate &amp;quot;Name&amp;quot; record is different it would still duplicate the name because the address is different.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11484?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 01:05:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6c8f33f4-9418-4bf7-8791-8a6eb912db0e</guid><dc:creator>Mike Cichy</dc:creator><description>Sorry, I should have explained that your example did not work because of the type mismatch: &amp;quot;name&amp;quot; is a string, the union of strings will not result in a cdt.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11483?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 01:04:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4bd79531-23e5-43c2-98af-17c0c565997c</guid><dc:creator>Mike Cichy</dc:creator><description>Right, but you should be able to just do union(oldCDT, oldCDT).&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11482?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 01:01:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b6908526-b56a-4dd6-86ab-c25dbca56935</guid><dc:creator>lesliem</dc:creator><description>When I tried to union(oldCDT.name,oldCDT.name) and save to newCDT it returned a blank CDT.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11480?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 00:57:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5917de57-8fff-440b-809f-55d5257d5dbd</guid><dc:creator>Mike Cichy</dc:creator><description>Leslie, you can do union() directly on CDTs: &lt;a href="https://forum.appian.com/suite/help/7.6/Set_Functions.html#union.28.29"&gt;forum.appian.com/.../Set_Functions.html&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11478?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 00:35:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ecc682f7-17e2-4bce-bb53-1c15cb0a934e</guid><dc:creator>lesliem</dc:creator><description>Right, so if my array is a pv of a CDT and include address, city, state, zip, phone I would like to get the information from the unique record that was gathered in the union().&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Having trouble removing duplicates from an array</title><link>https://community.appian.com/thread/11477?ContentTypeID=1</link><pubDate>Fri, 22 Aug 2014 00:19:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:527d550a-430d-49bd-8bab-0fa5f10d33a7</guid><dc:creator>colton.beck</dc:creator><description>When you say &amp;#39;get the rest of the information,&amp;#39; do you mean the values in ri!name not returned by union(ri!name,ri!name)?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>