<?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>Problem with the result of ER</title><link>https://community.appian.com/discussions/f/rules/22356/problem-with-the-result-of-er</link><description>Hello, 
 I would need the result of this Expression Rule in cod_provincia show me only the code of the provincia to which the municipio belongs. However, it is returning all the codes from my provincias table. 
 What am I doing wrong? 
 Thanks in advance</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Problem with the result of ER</title><link>https://community.appian.com/thread/87493?ContentTypeID=1</link><pubDate>Mon, 01 Nov 2021 21:33:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d41767a9-8241-47e8-b82e-f6a9bebdc8c5</guid><dc:creator>ajhick</dc:creator><description>&lt;p&gt;If the first two digits of the&amp;nbsp;&lt;span&gt;cod_municipality is the&amp;nbsp;cod_provincia then you can eliminate query2 and just use the left(cod_municipality, 2) function.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The better solution though would likely&amp;nbsp;be using a view in the database though.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with the result of ER</title><link>https://community.appian.com/thread/87468?ContentTypeID=1</link><pubDate>Mon, 01 Nov 2021 15:28:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3f3e67a7-66b9-4426-84a2-559516ce82ce</guid><dc:creator>lidiam0005</dc:creator><description>&lt;p&gt;The first two digits of the cod_municipality should appear as a value in the cod_provincia&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with the result of ER</title><link>https://community.appian.com/thread/87467?ContentTypeID=1</link><pubDate>Mon, 01 Nov 2021 15:26:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:11ef1b56-f0f5-4371-90bd-c5e3abad8f14</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;You&amp;#39;ll have to provide a bit more detail about what the result should be. For a given Municipios what value(s) should be appearing in the &amp;#39;&lt;span&gt;cod_provincia&amp;#39; attribute of the TIE_Municipios&amp;nbsp;datatype?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with the result of ER</title><link>https://community.appian.com/thread/87465?ContentTypeID=1</link><pubDate>Mon, 01 Nov 2021 15:18:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6ab9e780-8115-4793-bb4a-fce9336298d9</guid><dc:creator>lidiam0005</dc:creator><description>&lt;p&gt;Thanks for your answer.&lt;/p&gt;
&lt;p&gt;But, could you put an example to make the fn whereContains?&lt;br /&gt;In &amp;#39;query&amp;#39; I am collecting all the&amp;nbsp;municipios and in &amp;#39;query2&amp;#39; all the provincias.&lt;br /&gt;These tables are related, with&amp;nbsp;provincias being the parent table and&amp;nbsp;municipios being the child.&lt;br /&gt;The foreign key is cod_provincia.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with the result of ER</title><link>https://community.appian.com/thread/87463?ContentTypeID=1</link><pubDate>Mon, 01 Nov 2021 14:52:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:94862d5b-1218-4bcc-9a28-b02ed991dadc</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Your code is doing exactly what you&amp;#39;re asking it to do, which is setting the value of cod_provincia to ALL the values you retrieved into your &amp;#39;query2&amp;#39; local variable. If you are wanting to basically perform a &amp;quot;lookup&amp;quot; of the cod_proivincia based upon the value of the cod_municipio then you need to perform a fn!wherecontains() on the value of query2 based upon the value of the &lt;span&gt;cod_municipio&amp;nbsp;in the current iteration of your loop. But wihtout seeing the data you&amp;#39;ve retrieved into &amp;#39;query&amp;#39; or &amp;#39;query2&amp;#39; or the exact definitions of the relationships between those datasets it&amp;#39;s hard&amp;nbsp;to&amp;nbsp; be precise.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>