<?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: ArcGIS Pro field calculator if statements based on value of other field in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416545#M82505</link>
    <description>&lt;P&gt;Thanks. That would work, but I think an if statement incorporated into field calculator would be easier to incorporate into existing models in modelbuilder in this case.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Apr 2024 14:59:08 GMT</pubDate>
    <dc:creator>YusefSamari</dc:creator>
    <dc:date>2024-04-29T14:59:08Z</dc:date>
    <item>
      <title>ArcGIS Pro field calculator if statements based on value of other field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1415883#M82441</link>
      <description>&lt;P&gt;I am using ArcGIS Pro 3.1.3. I have a field full of dates, stored as a text field, arranged in the format dd/mm/yyyy. I want to extract the month value and store in a newly created field as an integer. If I just put:&lt;/P&gt;&lt;P&gt;!DateField![3:5]&lt;/P&gt;&lt;P&gt;in the field calculator, without using a code block, the new month field becomes populated, like I want it. However, I only want to extract the values from the date field if the value if the criteria in a DateTypeField, which lists the date type of the record (whether it pertains to specific date, or date range e.g. year), are met. Most of the dates are marked "D" in the date type field and these are the ones I want to populate the new month field for. For all other values of DateTypeField, I want the value of the month field to remain null.&lt;/P&gt;&lt;P&gt;My expression in the Code Block looks like this:&lt;/P&gt;&lt;P&gt;def reclass(Date, DateType):&lt;BR /&gt;if (DateType == "D"):&lt;BR /&gt;Date[3:5]&lt;/P&gt;&lt;P&gt;With correct indentation, which is lost when copying and pasting into this box. The expression passes the validation check. Then I use the following field calculator expression:&lt;/P&gt;&lt;P&gt;reclass(!DateField!,!DateTypeField!)&lt;/P&gt;&lt;P&gt;And it runs, but all values in the table remain NULL. Can anyone see where I am going wrong? Many thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 15:08:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1415883#M82441</guid>
      <dc:creator>YusefSamari</dc:creator>
      <dc:date>2024-04-26T15:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro field calculator if statements based on value of other field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1415913#M82446</link>
      <description>&lt;P&gt;The field calculator doesn't use any types that are pass-by-reference, so you have to return what you want like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def reclass(Date, DateType):
    if (DateType == "D"):
        return Date[3:5]
    return None&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 15:51:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1415913#M82446</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2024-04-26T15:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro field calculator if statements based on value of other field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416453#M82497</link>
      <description>&lt;P&gt;The field calculator will also respect a selection and only run on selected rows. So you could do a "select by attributes first (to select records where DateType equals D) and then run your initial calculation&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 12:45:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416453#M82497</guid>
      <dc:creator>RichardHowe</dc:creator>
      <dc:date>2024-04-29T12:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro field calculator if statements based on value of other field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416543#M82504</link>
      <description>&lt;P&gt;Many thanks. Just wondering what you mean by 'pass-by-reference', and also, how do you put a codeblock in the text on here?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 14:58:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416543#M82504</guid>
      <dc:creator>YusefSamari</dc:creator>
      <dc:date>2024-04-29T14:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro field calculator if statements based on value of other field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416545#M82505</link>
      <description>&lt;P&gt;Thanks. That would work, but I think an if statement incorporated into field calculator would be easier to incorporate into existing models in modelbuilder in this case.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 14:59:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416545#M82505</guid>
      <dc:creator>YusefSamari</dc:creator>
      <dc:date>2024-04-29T14:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro field calculator if statements based on value of other field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416580#M82508</link>
      <description>&lt;P&gt;This can be done with a &lt;A href="https://docs.python.org/3/reference/expressions.html#conditional-expressions" target="_self"&gt;Python 6.13. Conditional expressions; Python 3.x documentation&lt;/A&gt;, aka ternary operator, and doesn't require a code block:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;!DateField![3:5] if !DateTypeField! == "D" else None&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 29 Apr 2024 15:43:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416580#M82508</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2024-04-29T15:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro field calculator if statements based on value of other field</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416930#M82534</link>
      <description>&lt;P&gt;Nice! Many thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 09:14:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-field-calculator-if-statements-based-on/m-p/1416930#M82534</guid>
      <dc:creator>YusefSamari</dc:creator>
      <dc:date>2024-04-30T09:14:06Z</dc:date>
    </item>
  </channel>
</rss>

