<?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 Help Calculate field based on values in another field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/help-calculate-field-based-on-values-in-another/m-p/272255#M21032</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry to drop this on the community, but i can't seem to find a suitable example&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My target field is ???PRG_Parcel???.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I???m trying to write a function called ???answer??? that will return text to ???PRG_Parcel??? based on values in the ???Taxable??? field. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Input Table: table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Field Name: Field_Name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: answer()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Exp. type: Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def answer(!Taxable!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; if Taxable &amp;gt; 20000:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "'Y'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "'N'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried to do things a few different ways. Would anyone be so kind as to explain how I should be writing this code? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bundle.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Aug 2011 22:11:02 GMT</pubDate>
    <dc:creator>RichardThurau</dc:creator>
    <dc:date>2011-08-31T22:11:02Z</dc:date>
    <item>
      <title>Help Calculate field based on values in another field</title>
      <link>https://community.esri.com/t5/python-questions/help-calculate-field-based-on-values-in-another/m-p/272255#M21032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry to drop this on the community, but i can't seem to find a suitable example&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My target field is ???PRG_Parcel???.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I???m trying to write a function called ???answer??? that will return text to ???PRG_Parcel??? based on values in the ???Taxable??? field. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Input Table: table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Field Name: Field_Name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: answer()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Exp. type: Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def answer(!Taxable!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; if Taxable &amp;gt; 20000:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "'Y'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "'N'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried to do things a few different ways. Would anyone be so kind as to explain how I should be writing this code? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bundle.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2011 22:11:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calculate-field-based-on-values-in-another/m-p/272255#M21032</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-08-31T22:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help Calculate field based on values in another field</title>
      <link>https://community.esri.com/t5/python-questions/help-calculate-field-based-on-values-in-another/m-p/272256#M21033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Did you check out the pictoral image in this link down in the "Code Blocks" section?&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005s0000002m000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005s0000002m000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;It will visually give you an idea what needs to go where.&amp;nbsp; Also, there is no indentation in your example ensure that you are using proper indentation ( 2 or 4 spaces) in the def&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2011 22:14:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calculate-field-based-on-values-in-another/m-p/272256#M21033</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-08-31T22:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help Calculate field based on values in another field</title>
      <link>https://community.esri.com/t5/python-questions/help-calculate-field-based-on-values-in-another/m-p/272257#M21034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are pretty close. What you had wrong:&lt;/SPAN&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;The expression needs to pass the field to the code block, so the field (or fields) must go in the brackets there.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;The term inside the code block doesn't need to have the same name as the field, or have exclamation marks around it...&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;BR /&gt;&lt;SPAN&gt;The following ought to work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;STRONG&gt;Expression:&lt;/STRONG&gt; 
answer(!Taxable!)

&lt;STRONG&gt;Code Block:&lt;/STRONG&gt;
def answer(Tx):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if Tx &amp;gt; 20000:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "'Y'"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "'N'"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:17:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calculate-field-based-on-values-in-another/m-p/272257#M21034</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T13:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help Calculate field based on values in another field</title>
      <link>https://community.esri.com/t5/python-questions/help-calculate-field-based-on-values-in-another/m-p/272258#M21035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Stacy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Exactly the help I was looking for. This helps me with a lot of different things I've been working on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The visual examples are okay, but as someone who already knows how to program, you may not notice that none of these examples explicitly detail what the variables are describing. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The code was indented properly, it was just dropped in the forums text box.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your input though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks ESRI forums!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Sep 2011 13:52:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-calculate-field-based-on-values-in-another/m-p/272258#M21035</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2011-09-01T13:52:21Z</dc:date>
    </item>
  </channel>
</rss>

