<?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: I need to automatically calculate a field based on values from previous rows in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29861#M2352</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for your response, can you kindly relate the script above to feature layers instead as i can't really relate them as needed. Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Apr 2016 07:38:54 GMT</pubDate>
    <dc:creator>OLANIYANOLAKUNLE</dc:creator>
    <dc:date>2016-04-26T07:38:54Z</dc:date>
    <item>
      <title>I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29849#M2340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;I need to automatically calculate a field based on values from previous rows?I need to automatically calculate a field based on values from previous rows such that once the total of all the previous rows is greater than 450 and less than 500, the next row starts counting from 0 or the balance of what made the previous row greater than 500. The script below just calculates the sum of the cities point that falls within the county, I want something that would make the value of a row (i.e. row2) the addition of the value of row1 + value of row2 and so on till when it gets to 500, where it starts from 1 again. Kindly help me please.&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 08:59:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29849#M2340</guid>
      <dc:creator>OLANIYANOLAKUNLE</dc:creator>
      <dc:date>2016-04-13T08:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29850#M2341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you expand on your example so we may get a better understanding of what you are trying to do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 14:20:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29850#M2341</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-04-14T14:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29851#M2342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;previous link and advice can be found here if anyone is looking for background &lt;A href="https://community.esri.com/thread/175483"&gt;I need to automatically calculate a field based on values from previous rows &lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 14:31:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29851#M2342</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-14T14:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29852#M2343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like clarity is needed on both of these threads. Is there a way to combine both of them in order to consolidate and alleviate confusion?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 15:04:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29852#M2343</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-04-14T15:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29853#M2344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Waiting for clarification ... but that is not in our hands&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 15:27:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29853#M2344</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-14T15:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29854#M2345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reponse(s), what i want to achieve is to get the sum total of values from a field called population, but i really don't want the final sum, what i need is to get the sum as you loop through the rows (that's the population value)&amp;nbsp; i.e if &lt;/P&gt;&lt;P&gt;row 1 = 23 (row 1 would be 23 as there's no other row/record before row1)&lt;/P&gt;&lt;P&gt;row 2 = 30 (row 2 would be 30 + the value in row 1)&lt;/P&gt;&lt;P&gt;row 3 = 22 (row 3 would be 22 + the value in row 2), till you reach the last row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also want to add a constraint whereby if the sum of the population values in the rows becomes 500, the next row's value would start from zero or the difference that makes the 500 from the previous row. Thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Apr 2016 11:57:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29854#M2345</guid>
      <dc:creator>OLANIYANOLAKUNLE</dc:creator>
      <dc:date>2016-04-17T11:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29855#M2346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the quickest way would be to use a spreadsheet since you can copy the formula as you need it.&amp;nbsp; Since you don't seem to be doing thousands or rows nor have you indicated that this would be a daily calculation, it may be faster in the long run to set up a template spreadsheet, then bring it into Arc* for further work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Apr 2016 16:34:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29855#M2346</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-17T16:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29856#M2347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's such a bummer when the quickest way is to not use Python, but easier is easier... I agree with Dan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Apr 2016 19:35:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29856#M2347</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-04-17T19:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29857#M2348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first part of your request, if I understand it, seems straightforward enough, but I don't get the threshold condition.&amp;nbsp; You state if the population values in the rows becomes 500 (do you mean exactly 500?), then the next row's value is either zero or some difference.&amp;nbsp; Well, which is it, zero or the difference?&amp;nbsp; Can you present an example like the one above but showing the 500 threshold value in action?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Apr 2016 23:52:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29857#M2348</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-04-17T23:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29858#M2349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your views, the threshold is for any population value that falls between 450 - 500, now if the population for a particular row adds up to 503 - the population value of the next row would be (503 - 500) + the absolute population value of that row, likewise if the population for a particular row adds up to 498, then the population value of the next row would automatically start from&amp;nbsp; the absolute population value of that row as nothing would be added to the absolute population value for that particular row. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Apr 2016 09:22:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29858#M2349</guid>
      <dc:creator>OLANIYANOLAKUNLE</dc:creator>
      <dc:date>2016-04-18T09:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29859#M2350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excel wont work as we intend to use the form in ArcGIS Online?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Apr 2016 09:23:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29859#M2350</guid>
      <dc:creator>OLANIYANOLAKUNLE</dc:creator>
      <dc:date>2016-04-18T09:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29860#M2351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you use Python and create a gp tool?&amp;nbsp; that is, do you have access to ArcGIS Server?&amp;nbsp; I am not at a location that I can write /test Python script right now, but I had a similar need to looping thru records, and resetting a value every so often.&amp;nbsp; In my case, I used a cursor, and as the value of a field changed, my value incremented. Once it hit 10, it would reset to one and start again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so using a cursor and a variable to keep a running sum of your values...a quick test after each row in the cursor, reset as necessary.&amp;nbsp; Of course, this assumes one time need....not real time as records are added, since unless you add a field, and store the sum in the field (which could be totally legit, if it helps).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a snippet of my code...althoug not what you are needing, might help demonstrate (posting...then will edit to format) edited on iPad...may not be quite right on indentation (sorry)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;displayTrancsCnt = 1
displayID = 1
#&amp;nbsp;&amp;nbsp; The next lines are within a cursor, use counters and sum with tests
displayTransCnt += 1&amp;nbsp; # increments to count 10 trans for each group
if displayTransCnt == 11:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # once count hits 11...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; displayTransCnt = 1&amp;nbsp;&amp;nbsp;&amp;nbsp; # ..reset the count
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; displayID += 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # ..increment the ID for next set of 10
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; displayGrpCnt += 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # ..increment the sets of 10, before repeating
if displayGrpCnt == 11:&amp;nbsp; # once Grp hits 10 sets.., 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; displayGrpCnt = 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # ..resets to grp count to 1 again
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; displayID = 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # ..resets the ID to 1 again&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Calibri; font-size: 11.0pt;"&gt;&lt;SPAN style="font-size: 11pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:11:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29860#M2351</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-10T21:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29861#M2352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for your response, can you kindly relate the script above to feature layers instead as i can't really relate them as needed. Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2016 07:38:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29861#M2352</guid>
      <dc:creator>OLANIYANOLAKUNLE</dc:creator>
      <dc:date>2016-04-26T07:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29862#M2353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My python script calculates only the value of the immediate previous record instead of calculating the values of all preceding records before that particular record. The example (the image) below is the undesired output;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="196263" alt="Untitled.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/196269_Untitled.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;While the image below here is what i want to achieve;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="196264" alt="Untitled2.png" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/196270_Untitled2.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;This is my python script i used;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import da
CensusBldForm = "CensusBldForm"
Calculated_EA1=0
with arcpy.da.UpdateCursor(CensusBldForm, ["OBJECTID", "EstimatedPopulationinEA", "Calculated_EA"]) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Calculated_EA2 = row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = (Calculated_EA1 + Calculated_EA2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Calculated_EA1 = Calculated_EA2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/PRE&gt;&lt;P&gt;Kindly assist me with the above please.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:11:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29862#M2353</guid>
      <dc:creator>OLANIYANOLAKUNLE</dc:creator>
      <dc:date>2021-12-10T21:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29863#M2354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you want the cumulative sum, your line 09 is only swapping the two values, I think if you leave it out, ...EA1 should cumulate correctly...but check a few first&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 May 2016 04:07:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29863#M2354</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-04T04:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29864#M2355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this is a little simpler.&lt;/P&gt;&lt;P&gt;I put the field list in a variable to keep the code block skinny (easier to read)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy 
CensusBldForm = "CensusBldForm" 
vsum = 0 
flds = &lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;["OBJECTID", "EstimatedPopulationinEA", "Calculated_EA"]&lt;/SPAN&gt;
with arcpy.da.UpdateCursor(CensusBldForm, flds) as cursor: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vsum = vsum + row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # a fancy way of the same thing follows
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # vsum += row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = vsum
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row) &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:11:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29864#M2355</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-10T21:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29865#M2356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yup... that is the cumulative sum&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 May 2016 04:17:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29865#M2356</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-04T04:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29866#M2357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I also want to add a constraint whereby if the sum of the population values in the rows becomes 500, the next row's value would start from zero or the difference that makes the 500 from the previous row.&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/28817" target="_blank"&gt;OLANIYAN OLAKUNLE&lt;/A&gt;&amp;nbsp; - I think this will do what you want with the threshold reset, if I am understanding your description correctly:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vsum = vsum + row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if vsum &amp;gt;= 500:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vsum = vsum - 500
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = vsum
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;["OBJECTID", "EstimatedPopulationinEA", "Calculated_EA"]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;alculated_EA"]&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:11:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29866#M2357</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-10T21:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29867#M2358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ahh yes, the final detail&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 May 2016 09:18:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29867#M2358</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-04T09:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: I need to automatically calculate a field based on values from previous rows</title>
      <link>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29868#M2359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got the error below when i incorporated the lines of code you suggested;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;vsum = vsum + row[1]&lt;/P&gt;&lt;P&gt;TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;See my code;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;CensusBldForm = "SCensusBldForm"&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vsum = 0&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flds = ["OBJECTID", "EstimatedPopulationinEA", "Calculated_EA"]&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.UpdateCursor(CensusBldForm, flds) as cursor:&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vsum = vsum + row[1]&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if vsum &amp;gt;= 500:&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vsum = vsum - 500&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = vsum&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What do you think i'm doing wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jul 2016 20:19:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-to-automatically-calculate-a-field-based-on/m-p/29868#M2359</guid>
      <dc:creator>OLANIYANOLAKUNLE</dc:creator>
      <dc:date>2016-07-13T20:19:02Z</dc:date>
    </item>
  </channel>
</rss>

