<?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 Model Builder calculate field expression in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154436#M64079</link>
    <description>&lt;P&gt;I have a model that I would like to use the the following code to update a field "Permits" based on how many text occurrences are in "ParcelNum1" field based on the "PermitNum" field. I get the following error and need help figuring out what the issues is and all fields are text fields. I need this in model builder.&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;TABLE width="384px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="97px"&gt;OBJECTID&lt;/TD&gt;&lt;TD width="77px"&gt;PermitNum&lt;/TD&gt;&lt;TD width="70px"&gt;ParcelNum1&lt;/TD&gt;&lt;TD width="140px"&gt;Permits&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;1&lt;/TD&gt;&lt;TD width="77px"&gt;aa1123&lt;/TD&gt;&lt;TD width="70px"&gt;12345&lt;/TD&gt;&lt;TD width="140px"&gt;12345, 12346&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;2&lt;/TD&gt;&lt;TD width="77px"&gt;aa1123&lt;/TD&gt;&lt;TD width="70px"&gt;12346&lt;/TD&gt;&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;3&lt;/TD&gt;&lt;TD width="77px"&gt;BB3361&lt;/TD&gt;&lt;TD width="70px"&gt;67891&lt;/TD&gt;&lt;TD width="140px"&gt;67891, 67892, 37893&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;4&lt;/TD&gt;&lt;TD width="77px"&gt;BB3361&lt;/TD&gt;&lt;TD width="70px"&gt;67892&lt;/TD&gt;&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;5&lt;/TD&gt;&lt;TD width="77px"&gt;BB3361&lt;/TD&gt;&lt;TD width="70px"&gt;67893&lt;/TD&gt;&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;6&lt;/TD&gt;&lt;TD width="77px"&gt;UU9832&lt;/TD&gt;&lt;TD width="70px"&gt;11123&lt;/TD&gt;&lt;TD width="140px"&gt;11123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;7&lt;/TD&gt;&lt;TD width="77px"&gt;PP2225&lt;/TD&gt;&lt;TD width="70px"&gt;6989&lt;/TD&gt;&lt;TD width="140px"&gt;6988, 6989&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;8&lt;/TD&gt;&lt;TD width="77px"&gt;PP2225&lt;/TD&gt;&lt;TD width="70px"&gt;6988&lt;/TD&gt;&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Pre-Logic Script code:&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dict1 = dict()
with arcpy.da.SearchCursor('TableTest6',['ParcelNum1','Permit_Count','PermitNum']) as cursor:
    for row in cursor:
        if row[0] not in (None, "", " "):
            dict1.setdefault(row[0],[]).append(str(row[2]))
        
def concat(nf):
    x = None
    if nf in dict1t:
        x = ",".join(dict1[nf])
    return x&lt;/LI-CODE&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Permits = conact(!ParcelNum1! )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error.&lt;/P&gt;&lt;P&gt;ERROR 000539: Runtime error&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 2, in &amp;lt;module&amp;gt;&lt;BR /&gt;RuntimeError: cannot open 'TableTest6'&lt;/P&gt;&lt;P&gt;Failed to execute (Calculate Field (4)).&lt;/P&gt;</description>
    <pubDate>Thu, 17 Mar 2022 14:56:00 GMT</pubDate>
    <dc:creator>2Quiker</dc:creator>
    <dc:date>2022-03-17T14:56:00Z</dc:date>
    <item>
      <title>Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154436#M64079</link>
      <description>&lt;P&gt;I have a model that I would like to use the the following code to update a field "Permits" based on how many text occurrences are in "ParcelNum1" field based on the "PermitNum" field. I get the following error and need help figuring out what the issues is and all fields are text fields. I need this in model builder.&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;TABLE width="384px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="97px"&gt;OBJECTID&lt;/TD&gt;&lt;TD width="77px"&gt;PermitNum&lt;/TD&gt;&lt;TD width="70px"&gt;ParcelNum1&lt;/TD&gt;&lt;TD width="140px"&gt;Permits&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;1&lt;/TD&gt;&lt;TD width="77px"&gt;aa1123&lt;/TD&gt;&lt;TD width="70px"&gt;12345&lt;/TD&gt;&lt;TD width="140px"&gt;12345, 12346&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;2&lt;/TD&gt;&lt;TD width="77px"&gt;aa1123&lt;/TD&gt;&lt;TD width="70px"&gt;12346&lt;/TD&gt;&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;3&lt;/TD&gt;&lt;TD width="77px"&gt;BB3361&lt;/TD&gt;&lt;TD width="70px"&gt;67891&lt;/TD&gt;&lt;TD width="140px"&gt;67891, 67892, 37893&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;4&lt;/TD&gt;&lt;TD width="77px"&gt;BB3361&lt;/TD&gt;&lt;TD width="70px"&gt;67892&lt;/TD&gt;&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;5&lt;/TD&gt;&lt;TD width="77px"&gt;BB3361&lt;/TD&gt;&lt;TD width="70px"&gt;67893&lt;/TD&gt;&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;6&lt;/TD&gt;&lt;TD width="77px"&gt;UU9832&lt;/TD&gt;&lt;TD width="70px"&gt;11123&lt;/TD&gt;&lt;TD width="140px"&gt;11123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;7&lt;/TD&gt;&lt;TD width="77px"&gt;PP2225&lt;/TD&gt;&lt;TD width="70px"&gt;6989&lt;/TD&gt;&lt;TD width="140px"&gt;6988, 6989&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="97px"&gt;8&lt;/TD&gt;&lt;TD width="77px"&gt;PP2225&lt;/TD&gt;&lt;TD width="70px"&gt;6988&lt;/TD&gt;&lt;TD width="140px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Pre-Logic Script code:&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dict1 = dict()
with arcpy.da.SearchCursor('TableTest6',['ParcelNum1','Permit_Count','PermitNum']) as cursor:
    for row in cursor:
        if row[0] not in (None, "", " "):
            dict1.setdefault(row[0],[]).append(str(row[2]))
        
def concat(nf):
    x = None
    if nf in dict1t:
        x = ",".join(dict1[nf])
    return x&lt;/LI-CODE&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Permits = conact(!ParcelNum1! )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error.&lt;/P&gt;&lt;P&gt;ERROR 000539: Runtime error&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 2, in &amp;lt;module&amp;gt;&lt;BR /&gt;RuntimeError: cannot open 'TableTest6'&lt;/P&gt;&lt;P&gt;Failed to execute (Calculate Field (4)).&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 14:56:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154436#M64079</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2022-03-17T14:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154464#M64081</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/102454"&gt;@2Quiker&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Does it matter if the Permits field is populated for all rows?&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JakeSkinner_0-1647456504380.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36533iEFBFABC96DD86CEB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JakeSkinner_0-1647456504380.png" alt="JakeSkinner_0-1647456504380.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If not, you could do something like below:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dict = {}
with arcpy.da.SearchCursor(table, ['PermitNum1', 'ParcelNum']) as cursor:
    try:
        for row in cursor:
            dict.setdefault(str(row[0]), [])
            dict[str(row[0])].append(str(row[1]))
    except:
        pass
del cursor

with arcpy.da.UpdateCursor(table, ['PermitNum1', 'Permits']) as cursor:
    try:
        for row in cursor:
            permitsList = dict[row[0]]
            permits = ', '.join(permitsList)
            row[1] = permits
            cursor.updateRow(row)
    except:
        pass
del cursor&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 16 Mar 2022 18:49:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154464#M64081</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2022-03-16T18:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154503#M64082</link>
      <description>&lt;P&gt;Thanks for the response Jake but I was trying to this in Model Build with Calculate field.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 20:42:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154503#M64082</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2022-03-16T20:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154523#M64083</link>
      <description>&lt;P&gt;You can add this logic to the Calculate Field tool:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JakeSkinner_0-1647465779715.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36543i9F1083C74E64407F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JakeSkinner_0-1647465779715.png" alt="JakeSkinner_0-1647465779715.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;Or you can add a script to a model:&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/integrating-scripts-within-a-model.htm" target="_blank"&gt;https://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/integrating-scripts-within-a-model.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 21:23:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154523#M64083</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2022-03-16T21:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154550#M64084</link>
      <description>&lt;P&gt;Are you running the entire model, or just the Calculate Field (4)?&amp;nbsp; Have you tried to re-validate and run the entire model again?&lt;/P&gt;&lt;P&gt;The error says&amp;nbsp;&lt;SPAN&gt;cannot open 'TableTest6' which is output from Add Field (3).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If these are temp tables, they do not persist across sessions, and often you need to re-run the tool(s) that generate&amp;nbsp;the input (TableTest6) or it won't find them.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 22:05:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154550#M64084</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-03-16T22:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154574#M64085</link>
      <description>&lt;P&gt;I have re-validated and re-ran the model.&lt;/P&gt;&lt;P&gt;What do you mean by re-run the tool(s) that generated the input, example ?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 23:00:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154574#M64085</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2022-03-16T23:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154580#M64087</link>
      <description>&lt;P&gt;re-validate and re-run will do it.&lt;/P&gt;&lt;P&gt;Just meant to make sure that Add Field (3) runs right before the Calculate Field (4) runs to ensure that TableTest6 exists.&lt;/P&gt;&lt;P&gt;In the image, TableTest6 is the last one that shows a shadow behind it, meaning it has "ran".&amp;nbsp; If you were to save that model at that state, then open it up later, it will still show the shadow, but TableTest6 wouldn't exist (if it is temp table) until the tool that creates it is ran again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you see it put TableTest6 in the TOC?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 23:32:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154580#M64087</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-03-16T23:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154584#M64088</link>
      <description>&lt;P&gt;Upon closer inspection, noticed a few other things that might be causing issues.&lt;/P&gt;&lt;P&gt;You have a def called "concat(nf)", but the Expression block says "conact(!ParcelNum1!)" which is spelled incorrectly, so shouldn't even run that def. (also spelled this way in the search cursor which could cause it to not open TableTest6 if the field in the cursor doesn't exist)&lt;/P&gt;&lt;P&gt;also, sending !ParcelNum1! to it (&lt;SPAN&gt;&amp;nbsp;conact(!ParcelNum1! ))&lt;/SPAN&gt;, which, according to the table you supplied doesn't exist.&amp;nbsp; It says ParcelNum.&lt;/P&gt;&lt;P&gt;also, !ParcelNum! is a field getting passed to the def as "nf", but I see no iterator to go through the rows of that field to evaluate it.&amp;nbsp; I think it is the dictionary you are wanting to iterate through, not a field.&amp;nbsp; Might need something like:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;for key in dict1:
   x = ",".join(dict1[key])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, I've never put stuff in the Code Block outside of a def before, so not sure if that would even run (though, the error tends to suggest it is).&amp;nbsp; I would move all of the code within the def to ensure it runs, and in the order expected.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 23:50:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154584#M64088</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-03-16T23:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154845#M64095</link>
      <description>&lt;P&gt;Thank you for the replay, the example table I posted was incorrect and I have corrected it. I have verified that the fields are in the table and the code. The fields are&amp;nbsp; 'PermitNum','ParcelNum1' &amp;amp; 'Permits". I have struggled with calculate fields calculations so I apologize if I am not understanding correctly. I have re-validated the entire model and re-ran it. This is in ArcCatolog and not in ArcMap or Pro.&lt;/P&gt;&lt;P&gt;I have the following based on comments but I am still getting the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def update():
    dict1 = dict()
    with arcpy.da.SearchCursor("TableTest6",['ParcelNum1','Permit_Count','PermitNum']) as cursor:
        for row in cursor:
            if row[0] not in (None, "", " "):
                dict1.setdefault(row[0],[]).append(str(row[2]))
    if key in dict1t:
        x = ",".join(dict1[key])
    return x&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;ERROR 000539: Error running expression: update()&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 3, in update&lt;BR /&gt;RuntimeError: cannot open 'TableTest6'&lt;/P&gt;&lt;P&gt;Failed to execute (Calculate Field (5)).&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 15:45:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1154845#M64095</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2022-03-17T15:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1155037#M64100</link>
      <description>&lt;P&gt;This did technically work but only if I add the Table path to the code,&lt;/P&gt;&lt;P&gt;Table = "C:\temp\temp.gdb\table"&lt;/P&gt;&lt;P&gt;with arcpy.da.SearchCursor(Table,['ParcelNum1','Permit_Count','PermitNum']) as cursor:&lt;/P&gt;&lt;P&gt;Does not work with the Add Field output "TableTest6".&lt;/P&gt;&lt;P&gt;with arcpy.da.SearchCursor("TableTest6",['ParcelNum1','Permit_Count','PermitNum']) as cursor:&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 21:06:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1155037#M64100</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2022-03-17T21:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1155041#M64101</link>
      <description>&lt;P&gt;Funny, I thought I posted the below post earlier, but was still sitting as draft....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Still having issues with TableTest6.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have you tried hard coding the path to that table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(r'C:\path2table\TableTest6',['ParcelNum1','Permit_Count','PermitNum']) as cursor:&lt;/LI-CODE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can open the python window from Catalog and enter each command one at a time.&lt;/P&gt;&lt;P&gt;Can print individual variable results, etc.&amp;nbsp; This can often give you more info on where it is failing.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 17 Mar 2022 21:13:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1155041#M64101</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-03-17T21:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder calculate field expression</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1155048#M64102</link>
      <description>&lt;P&gt;Documentation for model builder says that items in the drop-down (TableTest6) is a variable.&lt;/P&gt;&lt;P&gt;You could try putting it in the cursor as a variable instead of text:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(TableTest6,['ParcelNum1','Permit_Count','PermitNum']) as cursor:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and see if that works.&lt;/P&gt;&lt;P&gt;Otherwise, just hardcode the path and you are don.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 21:29:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-calculate-field-expression/m-p/1155048#M64102</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-03-17T21:29:13Z</dc:date>
    </item>
  </channel>
</rss>

