<?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: Add a fieldname instead of value in calculate field using Python in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1025644#M37207</link>
    <description>&lt;P&gt;I hope the below helps.&lt;/P&gt;&lt;P&gt;This will replace the field I'm running the calculate field on with the value from the CODE field if the PLANT_ AREA field is not empty and replace it with the vale from field MEAN_AREA if it is empty.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DavinWalker2_3-1612996591291.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5786iF2C09828042F03E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DavinWalker2_3-1612996591291.png" alt="DavinWalker2_3-1612996591291.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Feb 2021 22:37:11 GMT</pubDate>
    <dc:creator>DavinWalker2</dc:creator>
    <dc:date>2021-02-10T22:37:11Z</dc:date>
    <item>
      <title>Add a fieldname instead of value in calculate field using Python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1025604#M37198</link>
      <description>&lt;P&gt;I am trying to convert this VB script in a model from ArcMap (10.7.1) to a model in ArcGIS Pro (3.7).&lt;/P&gt;&lt;P&gt;Calculating a field ADD1, and&amp;nbsp; using values from a field ADD2:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;Dim MainAddress&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;If Not [ADD1]= "" Then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;MainAddress = MainAddress &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Else&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;MainAddress = [ADD2]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;End if&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;______&lt;/P&gt;&lt;P&gt;I attempted this in the ArcGIS Pro codeblock: and was unable to replace the value with the &lt;STRONG&gt;fields&lt;/STRONG&gt; ADD1 or ADD2, so tried a text value instead to see if the logic at least was correct.&lt;/P&gt;&lt;P&gt;Runs as below, but how do I replace the value with values from another field?&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;def replace(mainaddress):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;if (mainaddress != ""):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;value = '5'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;elif (mainaddress == ""):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;value = '99'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;return value&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I have written the alternate select by attributes -&amp;gt; calculate, but I have a bunch of fields that need this kind of calculation.&lt;/P&gt;&lt;P&gt;Arcade solution welcome as an alternative..&lt;/P&gt;&lt;P&gt;Lakshmi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 21:41:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1025604#M37198</guid>
      <dc:creator>LakshmiSankaran</dc:creator>
      <dc:date>2021-02-10T21:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Add a fieldname instead of value in calculate field using Python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1025618#M37200</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - GeoNet, The Esri Community&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def replace(mainaddress):
    if (mainaddress != ""):
        value = '5'
    elif (mainaddress == ""):
        value = '99'
    return value&lt;/LI-CODE&gt;&lt;P&gt;Now... mainaddress can't be your field name, it can be a variable.&lt;/P&gt;&lt;P&gt;See the examples in this topic&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field.htm" target="_blank"&gt;Calculate Field (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;so&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;my_code = """
def replace(mainaddress):
    if (mainaddress != ""):
        value = '5'
    elif (mainaddress == ""):
        value = '99'
    return value
"""



 &lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 10 Feb 2021 22:09:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1025618#M37200</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-10T22:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Add a fieldname instead of value in calculate field using Python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1025644#M37207</link>
      <description>&lt;P&gt;I hope the below helps.&lt;/P&gt;&lt;P&gt;This will replace the field I'm running the calculate field on with the value from the CODE field if the PLANT_ AREA field is not empty and replace it with the vale from field MEAN_AREA if it is empty.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DavinWalker2_3-1612996591291.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5786iF2C09828042F03E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DavinWalker2_3-1612996591291.png" alt="DavinWalker2_3-1612996591291.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 22:37:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1025644#M37207</guid>
      <dc:creator>DavinWalker2</dc:creator>
      <dc:date>2021-02-10T22:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Add a fieldname instead of value in calculate field using Python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1025832#M37249</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Lakshmi&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 14:14:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1025832#M37249</guid>
      <dc:creator>LakshmiSankaran</dc:creator>
      <dc:date>2021-02-11T14:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Add a fieldname instead of value in calculate field using Python</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1026179#M37300</link>
      <description>&lt;P&gt;You welcome.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 06:10:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/add-a-fieldname-instead-of-value-in-calculate/m-p/1026179#M37300</guid>
      <dc:creator>DavinWalker2</dc:creator>
      <dc:date>2021-02-12T06:10:36Z</dc:date>
    </item>
  </channel>
</rss>

