<?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 Field Calculation - if statement (vbscript) in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/field-calculation-if-statement-vbscript/m-p/1037235#M25303</link>
    <description>&lt;P&gt;I was trying to do something I thought would be fairly simply. I need to sort a bunch of dates into quarters. I started by created a new field with just the month of the dates. So, it is numbers 1 through 12 in a field that is defined as a string [Quarter]&lt;BR /&gt;I then created a blank strong field called Qtr. The idea is, to check the value in [Quarter] and assign either Q1, Q2, Q3, or Q4 to [Qty]&lt;/P&gt;&lt;P&gt;here is the code:&lt;BR /&gt;Pre-Logic Script Codeblock&lt;/P&gt;&lt;P&gt;Dim val&lt;BR /&gt;If [Quarter] = "1" then&lt;BR /&gt;val = "Q1"&lt;BR /&gt;else if [Quarter] = "2" Then&lt;BR /&gt;val ="Q1"&lt;BR /&gt;else if [Quarter] = "3" Then&lt;BR /&gt;val ="Q1"&lt;BR /&gt;else if [Quarter] = "4" Then&lt;BR /&gt;val ="Q2"&lt;BR /&gt;else if [Quarter] = "5" Then&lt;BR /&gt;val ="Q2"&lt;BR /&gt;else if [Quarter] = "6" Then&lt;BR /&gt;val ="Q2"&lt;BR /&gt;else if [Quarter] = "7" Then&lt;BR /&gt;val ="Q3"&lt;BR /&gt;else if [Quarter] = "8" Then&lt;BR /&gt;val ="Q3"&lt;BR /&gt;else if [Quarter] = "9" Then&lt;BR /&gt;val ="Q3"&lt;BR /&gt;else if [Quarter] = "10" Then&lt;BR /&gt;val ="Q4"&lt;BR /&gt;else if [Quarter] = "11" Then&lt;BR /&gt;val ="Q4"&lt;BR /&gt;else if [Quarter] = "12" Then&lt;BR /&gt;val ="Q4"&lt;BR /&gt;else&lt;BR /&gt;val = ""&lt;BR /&gt;end if&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Code block&lt;BR /&gt;Qtr =&lt;/P&gt;&lt;P&gt;val&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Seems really simply and straight forward. I've found plenty of other threads with similar if statements that seemed to work for the folks using them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The geoprocessor window is spitting out generic errors.&lt;BR /&gt;General error executing calculator&lt;BR /&gt;ERROR 999999: Error executing function&lt;BR /&gt;Expected 'If'&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CaluclateField)&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Mar 2021 18:11:44 GMT</pubDate>
    <dc:creator>eXoScoriae</dc:creator>
    <dc:date>2021-03-16T18:11:44Z</dc:date>
    <item>
      <title>Field Calculation - if statement (vbscript)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculation-if-statement-vbscript/m-p/1037235#M25303</link>
      <description>&lt;P&gt;I was trying to do something I thought would be fairly simply. I need to sort a bunch of dates into quarters. I started by created a new field with just the month of the dates. So, it is numbers 1 through 12 in a field that is defined as a string [Quarter]&lt;BR /&gt;I then created a blank strong field called Qtr. The idea is, to check the value in [Quarter] and assign either Q1, Q2, Q3, or Q4 to [Qty]&lt;/P&gt;&lt;P&gt;here is the code:&lt;BR /&gt;Pre-Logic Script Codeblock&lt;/P&gt;&lt;P&gt;Dim val&lt;BR /&gt;If [Quarter] = "1" then&lt;BR /&gt;val = "Q1"&lt;BR /&gt;else if [Quarter] = "2" Then&lt;BR /&gt;val ="Q1"&lt;BR /&gt;else if [Quarter] = "3" Then&lt;BR /&gt;val ="Q1"&lt;BR /&gt;else if [Quarter] = "4" Then&lt;BR /&gt;val ="Q2"&lt;BR /&gt;else if [Quarter] = "5" Then&lt;BR /&gt;val ="Q2"&lt;BR /&gt;else if [Quarter] = "6" Then&lt;BR /&gt;val ="Q2"&lt;BR /&gt;else if [Quarter] = "7" Then&lt;BR /&gt;val ="Q3"&lt;BR /&gt;else if [Quarter] = "8" Then&lt;BR /&gt;val ="Q3"&lt;BR /&gt;else if [Quarter] = "9" Then&lt;BR /&gt;val ="Q3"&lt;BR /&gt;else if [Quarter] = "10" Then&lt;BR /&gt;val ="Q4"&lt;BR /&gt;else if [Quarter] = "11" Then&lt;BR /&gt;val ="Q4"&lt;BR /&gt;else if [Quarter] = "12" Then&lt;BR /&gt;val ="Q4"&lt;BR /&gt;else&lt;BR /&gt;val = ""&lt;BR /&gt;end if&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Code block&lt;BR /&gt;Qtr =&lt;/P&gt;&lt;P&gt;val&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Seems really simply and straight forward. I've found plenty of other threads with similar if statements that seemed to work for the folks using them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The geoprocessor window is spitting out generic errors.&lt;BR /&gt;General error executing calculator&lt;BR /&gt;ERROR 999999: Error executing function&lt;BR /&gt;Expected 'If'&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CaluclateField)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 18:11:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculation-if-statement-vbscript/m-p/1037235#M25303</guid>
      <dc:creator>eXoScoriae</dc:creator>
      <dc:date>2021-03-16T18:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculation - if statement (vbscript)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculation-if-statement-vbscript/m-p/1037244#M25304</link>
      <description>&lt;P&gt;is it not elseif rather than else if&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 18:26:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculation-if-statement-vbscript/m-p/1037244#M25304</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-03-16T18:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculation - if statement (vbscript)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-calculation-if-statement-vbscript/m-p/1037250#M25306</link>
      <description>&lt;P&gt;&amp;lt;face palm&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 18:30:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-calculation-if-statement-vbscript/m-p/1037250#M25306</guid>
      <dc:creator>eXoScoriae</dc:creator>
      <dc:date>2021-03-16T18:30:46Z</dc:date>
    </item>
  </channel>
</rss>

