<?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: Populate field with max value from other fields in same table in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71931#M5919</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can do this using the UpdateCursor.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;table = "XY"

rows = arcpy.UpdateCursor(table)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.field1 &amp;gt; row.field2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Num = row.field1
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif row.field1 &amp;lt; row.field2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Num = row.field2
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del row, rows&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:47:09 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2021-12-10T22:47:09Z</dc:date>
    <item>
      <title>Populate field with max value from other fields in same table</title>
      <link>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71930#M5918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am new to Python and v. 10.&amp;nbsp; I need to populate a type double field (NUM) based on the following criteria:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If field1 is equal to field2 then NUM is same value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If field1 is greater than field2 then NUM value is field1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If field1 is less than field2 then NUM value is field2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 May 2011 15:17:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71930#M5918</guid>
      <dc:creator>DonJohnson</dc:creator>
      <dc:date>2011-05-11T15:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Populate field with max value from other fields in same table</title>
      <link>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71931#M5919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can do this using the UpdateCursor.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;table = "XY"

rows = arcpy.UpdateCursor(table)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.field1 &amp;gt; row.field2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Num = row.field1
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif row.field1 &amp;lt; row.field2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Num = row.field2
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del row, rows&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:47:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71931#M5919</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-10T22:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Populate field with max value from other fields in same table</title>
      <link>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71932#M5920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the response but I failed to mention that I am attempting to do this in Field Calculator&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 May 2011 17:29:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71932#M5920</guid>
      <dc:creator>DonJohnson</dc:creator>
      <dc:date>2011-05-11T17:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Populate field with max value from other fields in same table</title>
      <link>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71933#M5921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thank you for the response but I failed to mention that I am attempting to do this in Field Calculator&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In v10, at the top of the Field Calculator, click the Radio Button beside Python to change the parser to that language.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In order to enable Python in earlier ArcGIS releases (9.x) you need to use the Field Calculator Tool found in the toolboxes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above script should then work for you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 May 2011 17:47:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71933#M5921</guid>
      <dc:creator>DonovanCameron</dc:creator>
      <dc:date>2011-05-11T17:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Populate field with max value from other fields in same table</title>
      <link>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71934#M5922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you - I came up with the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def NUM(ONE,TWO):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; if ONE &amp;lt; TWO:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAL=TWO&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; elif ONE &amp;gt; TWO:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAL=ONE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; elif ONE == TWO:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAL=ONE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return VAL&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 May 2011 18:32:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populate-field-with-max-value-from-other-fields-in/m-p/71934#M5922</guid>
      <dc:creator>DonJohnson</dc:creator>
      <dc:date>2011-05-11T18:32:24Z</dc:date>
    </item>
  </channel>
</rss>

