<?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: If - Then Statements in Field Calculator in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80007#M4652</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Other variation.&amp;nbsp; Note all fields are string.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P-L SC:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If [MUN] = "0901" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Bayonne"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0902" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "East Newark"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0903" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Guttenberg"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0904" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Harrison"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEFIF [MUN] = "0905" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Hoboken"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0906" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Jersey City"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0907" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Kearny"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN]= "0908" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "North Bergen"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0909" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Secaucus"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0910" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Union City"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0911" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Weehawken"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0912" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "West New York"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MUNI=output&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Dec 2013 17:04:59 GMT</pubDate>
    <dc:creator>deleted-user-o0qo22IL6bb6</dc:creator>
    <dc:date>2013-12-23T17:04:59Z</dc:date>
    <item>
      <title>If - Then Statements in Field Calculator</title>
      <link>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80006#M4651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a pretty simple set of replace functions I need to complete in an attribute table.&amp;nbsp; I have a feature class with approximately 135k records with a "MUN" attribute representing the four digit code of the applicable municipality.&amp;nbsp; I have a new field called "MUNI" in which I wish to populate the correct Municipal name.&amp;nbsp; There are 12 municipalities.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've worked on several variations of the code in field calculator but none seem to work; general syntax error.&amp;nbsp; Coding and languages were never my strong suit so it doesn't necessarily surprise me but nevertheless.&amp;nbsp; I had a working expression to do just this but it had been deleted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If [MUN] = 0901 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = Bayonne&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = 0902 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = East Newark&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = 0903 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = Guttenberg&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = 0904 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = Harrison&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEFIF [MUN] = 0905 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = Hoboken&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = 0906 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = Jersey City&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = 0907 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = Kearny&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN]= 0908 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = North Bergen&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = 0909 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = Secaucus&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = 0910 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = Union City&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = 0911 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = Weehawken&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = 0912 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [MUNI] = West New York&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A simple expression I should be able to build with little effort but not having done this for a bit is hanging me up!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2013 16:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80006#M4651</guid>
      <dc:creator>deleted-user-o0qo22IL6bb6</dc:creator>
      <dc:date>2013-12-23T16:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: If - Then Statements in Field Calculator</title>
      <link>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80007#M4652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Other variation.&amp;nbsp; Note all fields are string.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P-L SC:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If [MUN] = "0901" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Bayonne"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0902" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "East Newark"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0903" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Guttenberg"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0904" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Harrison"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEFIF [MUN] = "0905" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Hoboken"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0906" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Jersey City"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0907" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Kearny"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN]= "0908" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "North Bergen"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0909" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Secaucus"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0910" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Union City"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0911" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "Weehawken"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSEIF [MUN] = "0912" Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; output = "West New York"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MUNI=output&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2013 17:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80007#M4652</guid>
      <dc:creator>deleted-user-o0qo22IL6bb6</dc:creator>
      <dc:date>2013-12-23T17:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: If - Then Statements in Field Calculator</title>
      <link>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80008#M4653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Jason,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd use the python editor in Field editor. Then use "Show Codebook" and define a method (see screenshot). Your Pre-Logic Script Code should look something like this: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def customReplace(x):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if x=='0901':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 'Bayonne'
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif x=='0902':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 'East Newark'
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif x=='0903':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 'Guttenberg'
&amp;nbsp;&amp;nbsp; #etc.
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Not Found"&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Then call the method from the field calculator. Where "MUNI = "&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;customReplace( !MUN! )&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should work &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:05:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80008#M4653</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2021-12-10T23:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: If - Then Statements in Field Calculator</title>
      <link>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80009#M4654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your making this way to hard.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if you have a the muni code list simply add the table to an ArcGIS Session.&amp;nbsp; Join the feature to the table muni table via the 4 digit code.&amp;nbsp; then populate your name field with the name field from the muni table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Total time to set this up should be less than 2 minutes.&amp;nbsp; Then depending on your system configuration a little more time to perform the calculation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If it is a recurring operation MS Access is quick and easy as well.&amp;nbsp; Have your 4 digit code table in there as a LUT.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Create a query that joins the 2 tables and perform the update with the double click of a query.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2013 18:01:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80009#M4654</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2013-12-23T18:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: If - Then Statements in Field Calculator</title>
      <link>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80010#M4655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason's code comes the closest for VB, but you have to close all of the conditions with an End If statement at the end of the code block.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would use the Select Case syntax instead, since ELSEIF may fail after 7 levels (based on past experience with VBA).&amp;nbsp; My Code would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser: VB Script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Use Code Block: Checked&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Select Case [MUN]
 Case "0901" output = "Bayonne"
 Case "0902" output = "East Newark"
 Case "0903" output = "Guttenberg"
 Case "0904" output = "Harrison"
 Case "0905" output = "Hoboken"
 Case "0906" output = "Jersey City"
 Case "0907" output = "Kearny"
 Case "0908" output = "North Bergen"
 Case "0909" output = "Secaucus"
 Case "0910" output = "Union City"
 Case "0911" output = "Weehawken"
 Case "0912" output = "West New York"
 Case Else&amp;nbsp;&amp;nbsp;&amp;nbsp; output = [MUNI]
End Select&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression (MUNI field)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;output&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:05:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/80010#M4655</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-10T23:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: If - Then Statements in Field Calculator</title>
      <link>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/1232131#M44302</link>
      <description>&lt;P&gt;In case of&amp;nbsp;&lt;/P&gt;&lt;P&gt;i just need to put only One Name in the output field.&lt;/P&gt;&lt;P&gt;For Example&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case "0901" output = "Bayonne"&lt;BR /&gt;Case "0902" output = "East Newark"&lt;BR /&gt;Case "0903" output = "Guttenberg"&lt;BR /&gt;Case "0904" output = "Harrison"&lt;/P&gt;&lt;P&gt;Case "0805" output = "Hoboken"&lt;BR /&gt;Case "0906" output = "Jersey City"&lt;BR /&gt;Case "0807" output = "Kearny"&lt;BR /&gt;Case "0808" output = "North Bergen"&lt;BR /&gt;Case "0809" output = "Secaucus"&lt;BR /&gt;In 09 Series i have to put only "Bayone" and in 08 series i have to put only Newyork in this case what should i do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 09:59:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/if-then-statements-in-field-calculator/m-p/1232131#M44302</guid>
      <dc:creator>Raheel0600</dc:creator>
      <dc:date>2022-11-16T09:59:42Z</dc:date>
    </item>
  </channel>
</rss>

