<?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: Search for a string in multiple fields in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221676#M61035</link>
    <description>&lt;P&gt;perhaps.... and don't is key words like "where" for function names&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Expression
whr(!Spring!, !Summer!, !Fall!, !Winter!)

Code Block

def whr(Spring, Summer, Fall, Winter):
     if ('apple' in (Spring, Summer, Fall, Winter):
         return (Spring, Summer, Fall,Winter)
     else:
        return None&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 13 Oct 2022 17:35:24 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-10-13T17:35:24Z</dc:date>
    <item>
      <title>Search for a string in multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221585#M61022</link>
      <description>&lt;P&gt;I am attempting a field calculation that searches multiple fields for a specific string, in this case: apple. The string could be in any of the fields (Spring, Summer, Fall, Winter). I&amp;nbsp; want to return just one instance of the string in a new field.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I am having is that the &lt;EM&gt;&lt;STRONG&gt;Code Block does not like my syntax for a range of fields&lt;/STRONG&gt;&lt;/EM&gt;. See below for what is not working:&lt;/P&gt;&lt;P&gt;Expression&lt;/P&gt;&lt;P&gt;where(!Spring!)(!Summer!)(!Fall!)(!Winter!)&lt;/P&gt;&lt;P&gt;Code Block&lt;/P&gt;&lt;P&gt;def where(Spring)(Summer)(Fall)(Winter):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if ('apple' in (Spring)(Summer)(Fall)(Winter)):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return&amp;nbsp;(Spring)(Summer)(Fall)(Winter)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return None&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 15:36:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221585#M61022</guid>
      <dc:creator>RichardPenman1</dc:creator>
      <dc:date>2022-10-13T15:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Search for a string in multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221676#M61035</link>
      <description>&lt;P&gt;perhaps.... and don't is key words like "where" for function names&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Expression
whr(!Spring!, !Summer!, !Fall!, !Winter!)

Code Block

def whr(Spring, Summer, Fall, Winter):
     if ('apple' in (Spring, Summer, Fall, Winter):
         return (Spring, Summer, Fall,Winter)
     else:
        return None&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 13 Oct 2022 17:35:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221676#M61035</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-10-13T17:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Search for a string in multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221693#M61038</link>
      <description>&lt;P&gt;Thank you Dan.&amp;nbsp; I added one more parenthesis on line 7 after Winter to complete that line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your suggested script is an improvement because the syntax gets validated, runs, and receives no errors. Unfortunately in spite of the appearance of working, it returns NULLs and is not calculating into the new field.&amp;nbsp; If I use this same Code Block on just one field at a time it works perfectly. But adding more than one field to the search range produced NULLs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, when I attempt this with multiple fields it runs very fast. When I run it to just search one field at a time, it produces the expected output, but the process takes much longer. I assume because its actually searching.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 18:24:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221693#M61038</guid>
      <dc:creator>RichardPenman1</dc:creator>
      <dc:date>2022-10-13T18:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Search for a string in multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221743#M61043</link>
      <description>&lt;P&gt;What is it you want to return if "apple"is found in &lt;STRONG&gt;any&lt;/STRONG&gt; of the fields?&amp;nbsp; A specific value?&amp;nbsp; Concated values from all fields?&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 19:33:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221743#M61043</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-10-13T19:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Search for a string in multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221750#M61045</link>
      <description>&lt;P&gt;Just the name of the fruit; in this case it would be Apple. No concatenation required.&amp;nbsp; The issue I am trying to solve is that the string apple could be in any of the four fields in the range (spring, summer, etc). I want to search all four fields in one process, and have the fruit name return to a separate field&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 19:46:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221750#M61045</guid>
      <dc:creator>RichardPenman1</dc:creator>
      <dc:date>2022-10-13T19:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Search for a string in multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221760#M61047</link>
      <description>&lt;P&gt;This should work:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Expression
whr(!Spring!, !Summer!, !Fall!, !Winter!)

Code Block

def whr(Spring, Summer, Fall, Winter):
     if ('apple' in (Spring, Summer, Fall, Winter)):
         return "apple"
     else:
        return None&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If apple is found in any of the fields, it will return text string "apple".&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 19:55:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221760#M61047</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-10-13T19:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Search for a string in multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221765#M61050</link>
      <description>&lt;P&gt;A few people have posted suggestions, here's one that works with any number of fields and any value:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def setIfFound(value, *checks):
  return value if value in checks else None&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 13 Oct 2022 20:08:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221765#M61050</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2022-10-13T20:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: Search for a string in multiple fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221785#M61052</link>
      <description>&lt;P&gt;I like it.&amp;nbsp; I had forgotten about being able to load multiple variables in there with the asterisk......&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 20:27:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/search-for-a-string-in-multiple-fields/m-p/1221785#M61052</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-10-13T20:27:56Z</dc:date>
    </item>
  </channel>
</rss>

