<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Calculate Field Logic Ignoring Some Statements in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1326975#M72882</link>
    <description>&lt;P&gt;I am trying to calculate a field based on the values of 3 other fields. 2 are text and 1 is defined as double. When I run the following code only using the 2 text fields everything works as expected:&lt;/P&gt;&lt;P&gt;myCalc(!ASSIGNED!,!DEFAULTED!)&lt;/P&gt;&lt;P&gt;def myCalc(ASSIGNED,DEFAULTED,):&lt;BR /&gt;if (ASSIGNED=='YES')and(DEFAULTED=='NO'):&lt;BR /&gt;return 'NO'&lt;BR /&gt;elif (ASSIGNED=='YES')and(DEFAULTED=='YES'):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='YES'):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='NO'):&lt;BR /&gt;return 'YES'&lt;BR /&gt;else:&lt;BR /&gt;return 'INCONCLUSIVE'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I try to assess&amp;nbsp; against the 3rd field most of the statements get ignored and only a few are implemented as expected. No errors or warnings are generated. This results in most of the results coming in as Inconclusive as generated by the final statement. Given the data I am using no result should come in as inconclusive since no value is blank or null.&amp;nbsp; The logic for assessing the 3rd field is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;def myCalc(ASSIGNED,DEFAULTED,DISTANCE,):&lt;BR /&gt;&lt;FONT color="#000000"&gt;if (ASSIGNED=='YES')and(DEFAULTED=='NO'):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;return 'NO'&lt;/FONT&gt;&lt;BR /&gt;elif (ASSIGNED=='YES')and(DEFAULTED=='YES')and(DISTANCE&amp;lt;21):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='YES')and(DEFAULTED=='YES')and(DISTANCE&amp;gt;=21):&lt;BR /&gt;return 'NO'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='YES')and(DISTANCE&amp;lt;21):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='YES')and(DISTANCE&amp;gt;=21):&lt;BR /&gt;return 'NO'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='NO')and(DISTANCE&amp;lt;21):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='NO')and(DISTANCE&amp;gt;=21):&lt;BR /&gt;return 'NO'&lt;BR /&gt;else:&lt;BR /&gt;return 'INCONCLUSIVE'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the value for distance is placed in single quotes I get error&amp;nbsp;000539. Any help is greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Sep 2023 19:44:29 GMT</pubDate>
    <dc:creator>FlightDeck</dc:creator>
    <dc:date>2023-09-08T19:44:29Z</dc:date>
    <item>
      <title>Calculate Field Logic Ignoring Some Statements</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1326975#M72882</link>
      <description>&lt;P&gt;I am trying to calculate a field based on the values of 3 other fields. 2 are text and 1 is defined as double. When I run the following code only using the 2 text fields everything works as expected:&lt;/P&gt;&lt;P&gt;myCalc(!ASSIGNED!,!DEFAULTED!)&lt;/P&gt;&lt;P&gt;def myCalc(ASSIGNED,DEFAULTED,):&lt;BR /&gt;if (ASSIGNED=='YES')and(DEFAULTED=='NO'):&lt;BR /&gt;return 'NO'&lt;BR /&gt;elif (ASSIGNED=='YES')and(DEFAULTED=='YES'):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='YES'):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='NO'):&lt;BR /&gt;return 'YES'&lt;BR /&gt;else:&lt;BR /&gt;return 'INCONCLUSIVE'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I try to assess&amp;nbsp; against the 3rd field most of the statements get ignored and only a few are implemented as expected. No errors or warnings are generated. This results in most of the results coming in as Inconclusive as generated by the final statement. Given the data I am using no result should come in as inconclusive since no value is blank or null.&amp;nbsp; The logic for assessing the 3rd field is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;def myCalc(ASSIGNED,DEFAULTED,DISTANCE,):&lt;BR /&gt;&lt;FONT color="#000000"&gt;if (ASSIGNED=='YES')and(DEFAULTED=='NO'):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;return 'NO'&lt;/FONT&gt;&lt;BR /&gt;elif (ASSIGNED=='YES')and(DEFAULTED=='YES')and(DISTANCE&amp;lt;21):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='YES')and(DEFAULTED=='YES')and(DISTANCE&amp;gt;=21):&lt;BR /&gt;return 'NO'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='YES')and(DISTANCE&amp;lt;21):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='YES')and(DISTANCE&amp;gt;=21):&lt;BR /&gt;return 'NO'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='NO')and(DISTANCE&amp;lt;21):&lt;BR /&gt;return 'YES'&lt;BR /&gt;elif (ASSIGNED=='NO')and(DEFAULTED=='NO')and(DISTANCE&amp;gt;=21):&lt;BR /&gt;return 'NO'&lt;BR /&gt;else:&lt;BR /&gt;return 'INCONCLUSIVE'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the value for distance is placed in single quotes I get error&amp;nbsp;000539. Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 19:44:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1326975#M72882</guid>
      <dc:creator>FlightDeck</dc:creator>
      <dc:date>2023-09-08T19:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Logic Ignoring Some Statements</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1326984#M72883</link>
      <description>&lt;P&gt;Can you tell which statements are being correctly calculated? And are you including the distance field in the myCalc initialization?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;myCalc(!ASSIGNED!,!DEFAULTED!,!DISTANCE!)&lt;/LI-CODE&gt;&lt;P&gt;And when adding code (especially Python, where indentation is important) use the &lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_self"&gt;Code Syntax&lt;/A&gt; tool.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 20:10:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1326984#M72883</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-09-08T20:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Logic Ignoring Some Statements</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1326993#M72884</link>
      <description>&lt;P&gt;Thank you for the Code Syntax information.&lt;/P&gt;&lt;P&gt;Working Code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;myCalc(!ASSIGNED!,!DEFAULTED!)

def myCalc(ASSIGNED,DEFAULTED):
    if (ASSIGNED=='YES')and(DEFAULTED=='NO'):
        return 'NO'
    elif (ASSIGNED=='YES')and(DEFAULTED=='YES'):
        return 'YES'
    elif (ASSIGNED=='NO')and(DEFAULTED=='YES'):
        return 'YES'   
    elif (ASSIGNED=='NO')and(DEFAULTED=='NO'):
        return 'YES'
    else:
        return 'INCONCLUSIVE'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Broken Code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;myCalc(!ASSIGNED!,!DEFAULTED!,!DISTANCE!)

def myCalc(ASSIGNED,DEFAULTED,DISTANCE,):
    if (ASSIGNED=='YES')and(DEFAULTED=='NO'):
        return 'NO'    
    elif (ASSIGNED=='YES')and(DEFAULTED=='YES')and(DISTANCE&amp;lt;21):
        return 'YES'
    elif (ASSIGNED=='YES')and(DEFAULTED=='YES')and(DISTANCE&amp;gt;=21):
        return 'NO'    
    elif (ASSIGNED=='NO')and(DEFAULTED=='YES')and(DISTANCE&amp;lt;21):
        return 'YES' 
    elif (ASSIGNED=='NO')and(DEFAULTED=='YES')and(DISTANCE&amp;gt;=21):
        return 'NO'
    elif (ASSIGNED=='NO')and(DEFAULTED=='NO')and(DISTANCE&amp;lt;21):
        return 'YES'
    elif (ASSIGNED=='NO')and(DEFAULTED=='NO')and(DISTANCE&amp;gt;=21):
        return 'NO'
    else:
        return 'INCONCLUSIVE'&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;After looking at the results more closely only the 5th elif seems to be returning a yes result, but it is ignoring the distance portion of the statement thus returning yes for distances over 21. Hopefully this helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 20:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1326993#M72884</guid>
      <dc:creator>FlightDeck</dc:creator>
      <dc:date>2023-09-08T20:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Logic Ignoring Some Statements</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1326999#M72885</link>
      <description>&lt;P&gt;I ran your code on a test file and it returned all the expected results. I used a different return on if to make sure they were all being evaluated correctly.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="python.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/80252i24AABB8CA431974C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="python.png" alt="python.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 20:49:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1326999#M72885</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-09-08T20:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Logic Ignoring Some Statements</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1327009#M72888</link>
      <description>&lt;P&gt;Thanks Ken, I shut down ArcPro, reopened the program and repasted the code and its now working. No Idea what the issue was but restarting seems to have cleared it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 21:09:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1327009#M72888</guid>
      <dc:creator>FlightDeck</dc:creator>
      <dc:date>2023-09-08T21:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field Logic Ignoring Some Statements</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1327012#M72889</link>
      <description>&lt;LI-CODE lang="python"&gt;def myCalc(ASSIGNED, DEFAULTED, DISTANCE=None):
    if ASSIGNED == 'YES':
        if DEFAULTED == 'YES':
            if DISTANCE &amp;lt; 21:
                return 'YES'
            return 'NO'
        return 'SOMETHING' 
    elif ASSIGNED=='NO':
        if DEFAULTED == 'YES':
            if DISTANCE &amp;lt; 21:
                return 'YES' 
            return 'NO'
        else:
            if DISTANCE &amp;lt; 21:
                return 'YES'
            return 'NO'
    else:
        return 'INCONCLUSIVE'&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 08 Sep 2023 21:18:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-logic-ignoring-some-statements/m-p/1327012#M72889</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-09-08T21:18:48Z</dc:date>
    </item>
  </channel>
</rss>

