<?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>Compare each item one by one in two arrays</title><link>https://community.appian.com/discussions/f/general/22533/compare-each-item-one-by-one-in-two-arrays</link><description>Hi 
 I need to compare each item in two arrays 
 e.g. 
 local!dtmdata: { 9, 9, 33, 33 }, local!databaseData: { 9, 33, 33, 33 } 
 i have tried: 
 a!localVariables( 
 local!dtmdata: { 9, 9, 33, 33 }, local!databaseData: { 9, 33, 33, 33 }, local!notAtIndex</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Compare each item one by one in two arrays</title><link>https://community.appian.com/thread/88121?ContentTypeID=1</link><pubDate>Thu, 18 Nov 2021 09:25:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b7634277-ef4f-4bc6-a1e4-5648eee69117</guid><dc:creator>nikolas</dc:creator><description>&lt;p&gt;Wow, so simple. I was definitely overcomplicating it.&amp;nbsp;Thank you!!!!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compare each item one by one in two arrays</title><link>https://community.appian.com/thread/88096?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 20:33:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fa74299c-38f1-475e-9b18-2b4281736b20</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Few ways to do this, but Stefan&amp;#39;s solution is by far the most efficient.&amp;nbsp; However I might utilize a!foreach() with checking the max() length of either array to ensure all scenarios will be covered, and allow for scalability (say you want to ignore null values in the future).&amp;nbsp; If we can spare the extra ~1.5 ms:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!dtmdata: {9, 9, 33, 33},
  local!databaseData: {9, 33, 33, 33},

  a!forEach(
    items: 1+enumerate(max(count(local!dtmdata),count(local!databaseData))),
    expression: if(
      index(local!dtmdata,fv!index,null)=index(local!databaseData,fv!index,null),
      {},
      fv!index
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compare each item one by one in two arrays</title><link>https://community.appian.com/thread/88082?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 19:09:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a1f3200b-f7be-49c9-9ea7-e154a7f09687</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1637176015119v1.png" alt=" " /&gt; ...&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(

  local!dtmdata: { 9, 9, 33, 33 },
  local!databaseData: { 9, 33, 33, 33 },
  
  local!notAtIndex: a!forEach(
    items: local!dtmdata,
    expression: if(
      /* using index() here as it will allow the logic to run without breaking even if arrays are different lengths */
      index(local!databaseData, fv!index, null()) = fv!item,
      {},
      fv!index
    )
  ),
  
  local!notAtIndex
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1637176166603v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compare each item one by one in two arrays</title><link>https://community.appian.com/thread/88081?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 19:06:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:08118140-df37-47f4-a34b-46d3ce6e8ad2</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!dtmdata: {9, 9, 33, 33},
  local!databaseData: {9, 33, 33, 33},
  where(local!dtmdata &amp;lt;&amp;gt; local!databaseData)
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>