<?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 Re: Attribute Table- Field calculation using conditional IF in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707490#M23444</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If [Start_time] is defined as a numeric field, then you don't need the quotes around the value ([Start_time] = 1).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[Period_Sta] is a string field &amp;amp; [Start_time] is defined as Double. Even after removing the "", it sends the same error message: "There was a failure during processing".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jan 2012 11:26:55 GMT</pubDate>
    <dc:creator>BabakMirshahi</dc:creator>
    <dc:date>2012-01-05T11:26:55Z</dc:date>
    <item>
      <title>Attribute Table- Field calculation using conditional IF</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707487#M23441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To calculate the values in Field: "Start_time" using those in Field: "Period_Sta", I tried expression below. However it doesn't work. Can anybody help to debug it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If [Period_Sta] =="01/01" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [Start_time]= ???1???&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elseif&amp;nbsp; [Period_Sta] == "01/04" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [Start_time]= ???91???&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elseif&amp;nbsp; [Period_Sta] == "30/09" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [Start_time]= ???273???&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elseif&amp;nbsp; [Period_Sta] == "31/12" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [Start_time]= ???365???&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end if&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 13:09:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707487#M23441</guid>
      <dc:creator>BabakMirshahi</dc:creator>
      <dc:date>2012-01-04T13:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute Table- Field calculation using conditional IF</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707488#M23442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If [Start_time] is defined as a numeric field, then you don't need the quotes around the value ([Start_time] = 1).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 14:13:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707488#M23442</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-01-04T14:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute Table- Field calculation using conditional IF</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707489#M23443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;[Period_Sta] is a string field &amp;amp; [Start_time] is defined as Double. Even after removing the "", it sends the same error message: "There was a failure during processing".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 07:25:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707489#M23443</guid>
      <dc:creator>BabakMirshahi</dc:creator>
      <dc:date>2012-01-05T07:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute Table- Field calculation using conditional IF</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707490#M23444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If [Start_time] is defined as a numeric field, then you don't need the quotes around the value ([Start_time] = 1).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[Period_Sta] is a string field &amp;amp; [Start_time] is defined as Double. Even after removing the "", it sends the same error message: "There was a failure during processing".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 11:26:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707490#M23444</guid>
      <dc:creator>BabakMirshahi</dc:creator>
      <dc:date>2012-01-05T11:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute Table- Field calculation using conditional IF</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707491#M23445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;An update cursor in Python would be much easier to format this, but if you wanted to do it in the field calculator, the Python formatted code would look like this ugly thing here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;gp.CalculateField_management(myFC, "Start_time", "returnvalue(!Period_Sta!)", "PYTHON", "def returnvalue(periodStaFieldValue):\\n if periodStaFieldValue == '01/01':\\n&amp;nbsp;&amp;nbsp; return '1'\\n elif periodStaFieldValue == "01/04":\\n&amp;nbsp;&amp;nbsp; return '91'\\n elif periodStaFieldValue == "30/09":\\n&amp;nbsp;&amp;nbsp; return '273'&amp;nbsp;&amp;nbsp; \\n elif periodStaFieldValue == "31/12":\\n&amp;nbsp;&amp;nbsp; return '365'")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or in an update cursor...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;updateRows = arcpy.UpdateCursor(myFC)
for updateRow in updateRows:
&amp;nbsp;&amp;nbsp; if updateRow.Period_Sta ==&amp;nbsp; '01/01':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.Start_time = '1'
&amp;nbsp;&amp;nbsp; elif updateRow.Period_Sta ==&amp;nbsp; '01/04':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.Start_time = '91'
&amp;nbsp;&amp;nbsp; elif updateRow.Period_Sta ==&amp;nbsp; '30/09':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.Start_time = '273'
&amp;nbsp;&amp;nbsp; elif updateRow.Period_Sta ==&amp;nbsp; '31/12':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateRow.Start_time = '365'
&amp;nbsp;&amp;nbsp; updateRows.updateRow(updateRow)
del updateRow, updateRows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:43:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707491#M23445</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T05:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute Table- Field calculation using conditional IF</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707492#M23446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;To calculate the values in Field: "Start_time" using those in Field: "Period_Sta", I tried expression below. However it doesn't work. Can anybody help to debug it?&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;If [Period_Sta] =="01/01" Then&lt;BR /&gt; [Start_time]= �??1�?�&lt;BR /&gt;elseif&amp;nbsp; [Period_Sta] == "01/04" Then&lt;BR /&gt; [Start_time]= �??91�?�&lt;BR /&gt;elseif&amp;nbsp; [Period_Sta] == "30/09" Then&lt;BR /&gt; [Start_time]= �??273�?�&lt;BR /&gt;elseif&amp;nbsp; [Period_Sta] == "31/12" Then&lt;BR /&gt; [Start_time]= �??365�?�&lt;BR /&gt;end if&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try adding an unqualified Else condition at the end that calculates [Start_time] = [Start_time] if none of the other conditions are met.&amp;nbsp; Also, if [Period_Sta] has Null values you either need to select non-Null values first or else make the first condition If IsNull([Period_Sta]) Then [Start_time] = [Start_time]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 19:29:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/attribute-table-field-calculation-using/m-p/707492#M23446</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2012-01-05T19:29:55Z</dc:date>
    </item>
  </channel>
</rss>

