<?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>retrieve key field in dictionary from value</title><link>https://community.appian.com/discussions/f/new-to-appian/29731/retrieve-key-field-in-dictionary-from-value</link><description>Hello everyone. 
 I want to retrieve the key field in the dictionary(queried from cdt) based on the value present. 
 I have the data set in following order. 
 txt1 112 (Number (Decimal)) 
 txt2 113 (Number (Decimal)) 
 txt3 114 (Number (Decimal)) 
 txt4</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: retrieve key field in dictionary from value</title><link>https://community.appian.com/thread/117950?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 19:57:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b5af0bf7-6f5d-4520-a883-2ac486cee0a7</guid><dc:creator>Richard Michaelis</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!dictionary:{
    txt1:112,
    txt2:113,
    txt3:114,
    txt4:115
  },
  a!forEach(
    items:a!keys(local!dictionary),
    expression: a!localVariables(
      if(
        todecimal(index(local!dictionary, fv!item,null))=ri!input,
        fv!item,
        {}
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: retrieve key field in dictionary from value</title><link>https://community.appian.com/thread/117940?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 15:47:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2444d110-dada-4333-9471-591d3f4aea42</guid><dc:creator>Mathieu Drouin</dc:creator><description>&lt;p&gt;Here&amp;#39;s a version that takes the dictionary as an input and casts it to a map.&lt;pre class="ui-code" data-mode="text"&gt;reject(
  fn!isnull,
  a!forEach(
    items: a!keys(cast(typeof(a!map()), ri!dictionary)),
    expression: a!localVariables(
      local!value: todecimal(index(ri!dictionary, fv!item, null)),
      if(local!value = ri!input, fv!item, null)
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: retrieve key field in dictionary from value</title><link>https://community.appian.com/thread/117937?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 15:31:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b470c7a1-a916-49b9-959c-56f57592d26a</guid><dc:creator>maaaaj0001</dc:creator><description>&lt;p&gt;&lt;span&gt;Hello Mathieu Drouin,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here dictionary is the output from the query entity.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;a!keys will through the following error.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;Expression evaluation error at function a!keys [line 44]: The passed parameter(s) are of the wrong type. Received the type List of Variant.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: retrieve key field in dictionary from value</title><link>https://community.appian.com/thread/117935?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 15:06:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1e4d5e2c-be97-4e05-8a08-d76affd5085b</guid><dc:creator>Mathieu Drouin</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!dictionary: { txt1: 112, txt2: 113, txt3: 114, txt4: 115 },
  reject(
    fn!isnull,
    a!forEach(
      items: a!keys(local!dictionary),
      expression: a!localVariables(
        local!value: todecimal(index(local!dictionary, fv!item, null)),
        if(local!value = ri!input, fv!item, null)
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>