<?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: ArcGIS Pro 3.1.7 - Calculate Fields geoprocessing not using expression! in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-pro-3-1-7-calculate-fields-geoprocessing/m-p/1353541#M69285</link>
    <description>&lt;P&gt;It would be helpful if you posted the contents of the expression variable and any errors that come up when attempting to run the tool.&lt;/P&gt;&lt;P&gt;The tool is expecting a Value Table which is essentially an array of arrays. If you enclosed your value table in quotes it isn't getting the proper input. I am also wondering what the [0] at the end of each line is for?&lt;/P&gt;&lt;P&gt;I'm thinking this would work:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;arcpy.management.CalculateFields(in_table=fc, expression_type="PYTHON3", fields=[["Detached", "!Detached!*!Ratio!", ""], ["Total", "!Total!*!Ratio!", ""]])[0]
expression = [["Detached", "!Detached!*!Ratio!", ""], ["Total", "!Total!*!Ratio!", ""]]
arcpy.management.CalculateFields(in_table=fc, expression_type="PYTHON3", fields=expression)[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Nov 2023 16:00:38 GMT</pubDate>
    <dc:creator>GIS-Chops</dc:creator>
    <dc:date>2023-11-27T16:00:38Z</dc:date>
    <item>
      <title>ArcGIS Pro 3.1.7 - Calculate Fields geoprocessing not using expression!</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-3-1-7-calculate-fields-geoprocessing/m-p/1352545#M69277</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a simple script using CalculateFields geoprocessing tool. As part of my script, I build an expression in a loop for fields to calculate. However, it is not working...&lt;/P&gt;&lt;P&gt;If I use hard-coded field names and expression for calculation, it works.&lt;/P&gt;&lt;P&gt;Why my 'expression' string variable is not working? It is exactly the same as the hard-coded string...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.CalculateFields(in_table=fc, expression_type="PYTHON3", fields=[["Detached", "!Detached!*!Ratio!", ""], ["Total", "!Total!*!Ratio!", ""]])[0]

arcpy.management.CalculateFields(in_table=fc, expression_type="PYTHON3", fields=expression)[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2023 14:50:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-3-1-7-calculate-fields-geoprocessing/m-p/1352545#M69277</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-11-22T14:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.1.7 - Calculate Fields geoprocessing not using expression!</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-3-1-7-calculate-fields-geoprocessing/m-p/1352663#M69278</link>
      <description>&lt;P&gt;I found a workaround... Instead of dealing with building an 'expression' string variable in a for loop to calculate all fields with CalculateFields, I am calculating fields directly in the for loop, one by one with&amp;nbsp; arcpy.management.CalculateField. It is just as good and the syntax is much easier!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2023 16:59:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-3-1-7-calculate-fields-geoprocessing/m-p/1352663#M69278</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-11-22T16:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.1.7 - Calculate Fields geoprocessing not using expression!</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-3-1-7-calculate-fields-geoprocessing/m-p/1353541#M69285</link>
      <description>&lt;P&gt;It would be helpful if you posted the contents of the expression variable and any errors that come up when attempting to run the tool.&lt;/P&gt;&lt;P&gt;The tool is expecting a Value Table which is essentially an array of arrays. If you enclosed your value table in quotes it isn't getting the proper input. I am also wondering what the [0] at the end of each line is for?&lt;/P&gt;&lt;P&gt;I'm thinking this would work:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;arcpy.management.CalculateFields(in_table=fc, expression_type="PYTHON3", fields=[["Detached", "!Detached!*!Ratio!", ""], ["Total", "!Total!*!Ratio!", ""]])[0]
expression = [["Detached", "!Detached!*!Ratio!", ""], ["Total", "!Total!*!Ratio!", ""]]
arcpy.management.CalculateFields(in_table=fc, expression_type="PYTHON3", fields=expression)[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2023 16:00:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-3-1-7-calculate-fields-geoprocessing/m-p/1353541#M69285</guid>
      <dc:creator>GIS-Chops</dc:creator>
      <dc:date>2023-11-27T16:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.1.7 - Calculate Fields geoprocessing not using expression!</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-3-1-7-calculate-fields-geoprocessing/m-p/1353567#M69286</link>
      <description>&lt;P&gt;Thanks for looking at this post.&lt;/P&gt;&lt;P&gt;The content of the expression variable is the second line of the code, as below:&lt;/P&gt;&lt;PRE&gt;[["Detached", "!Detached!*!Ratio!", ""], ["Total", "!Total!*!Ratio!", ""]]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;As you mentioned, the CalculateFields is expecting a Value table and here I tried to built a string. In fact, I tried to reuse the syntax provided when you export ModelBuilder to python... hence the [0] which I do not either understand its use.&lt;/P&gt;&lt;P&gt;As for error message, on runtime, Python simply ignore the CalculateFields!&lt;/P&gt;&lt;P&gt;As I said, using arcpy.management.CalculateField in a loop is an excellent workaround, using simple string variable (no need for Value table)&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2023 16:26:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-3-1-7-calculate-fields-geoprocessing/m-p/1353567#M69286</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-11-27T16:26:57Z</dc:date>
    </item>
  </channel>
</rss>

