<?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>Querying from local data</title><link>https://community.appian.com/discussions/f/general/17584/querying-from-local-data</link><description>Hi All, 
 I have queried the data from table and have stored in some local variable. 
 User have option to select three values: LOB2,LOB3,LOB4. Now based on these selected values i have to query the id 
 please help me to make changes in the below code</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Querying from local data</title><link>https://community.appian.com/thread/69311?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2019 20:31:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e3fe4c22-e853-45f1-803c-7454998a9303</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;For example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!data:{
    {id:1, lob2:&amp;quot;Commercial Banking&amp;quot;, lob3:null ,lob4:null},
    {id:2, lob2:&amp;quot;Commercial Banking&amp;quot;, lob3:&amp;quot;Commercial Banking&amp;quot;, lob4:null},
    {id:3, lob2:&amp;quot;Commercial Banking&amp;quot;, lob3:&amp;quot;Commercial Banking&amp;quot;, lob4:&amp;quot;CMB&amp;quot;},
    {id:4, lob2:&amp;quot;Commercial Banking&amp;quot;, lob3:&amp;quot;Commercial Banking&amp;quot;, lob4:&amp;quot;GPB&amp;quot;},
    {id:5, lob2:&amp;quot;Commercial Banking&amp;quot;, lob3:&amp;quot;Commercial Banking&amp;quot;, lob4:&amp;quot;RBWM&amp;quot;},
    {id:6, lob2:&amp;quot;Commercial Banking&amp;quot;, lob3:&amp;quot;Commercial Banking&amp;quot;, lob4:&amp;quot;HOST&amp;quot;}
  },

  local!selectedLOB2: &amp;quot;Commercial Banking&amp;quot;,
  local!selectedLOB3: &amp;quot;Commercial Banking&amp;quot;,
  local!selectedLOB4: &amp;quot;GPB&amp;quot;,

  local!lob2Indices: wherecontains(local!selectedLOB2, touniformstring(index(local!data,&amp;quot;lob2&amp;quot;,null))),
  local!lob3Indices: wherecontains(local!selectedLOB3, touniformstring(index(local!data,&amp;quot;lob3&amp;quot;,null))),
  local!lob4Indices: wherecontains(local!selectedLOB4, touniformstring(index(local!data,&amp;quot;lob4&amp;quot;,null))),
  
  /* have to do a nested intersection here since intersection() only accepts 2 arrays */
  local!matchAllIndices: intersection(
    local!lob2Indices,
    intersection(
      local!lob3Indices,
      local!lob4Indices
    )
  ),
  
  local!id: index(
    local!data.id,
    local!matchAllIndices
  ),
  
  local!id
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Querying from local data</title><link>https://community.appian.com/thread/69310?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2019 20:28:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:396256fa-3a0a-46ca-9273-798d35941009</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Your index() call ends up passing in all members of the array multiple times - the whole set, then all the lob3 matches, then the one lob4 match.&amp;nbsp; What you should be doing is getting the indices (if necessary) using your whereContains lines, and then finding the items in the original array that match all 3 (though it seems you could just look up the position of the match in lob4, with the current data set anyway).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>