<?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 Arcade syntax in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331043#M6749</link>
    <description>&lt;P&gt;In an arcade attribute expression I'm counting all of the rows in a layer using the filter. The below code is working.&lt;/P&gt;&lt;P&gt;This Arcade code correctly returns a count of all species in the layer matching the value of the species point clicked for the popup.&lt;/P&gt;&lt;P&gt;//accepted records - working correctly&lt;BR /&gt;Count(&lt;BR /&gt;Filter($layer, "Species = '" + replace($feature.species, "'","''") + "'")&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;I would also like to filter if row batch number is not null. I can't seem to get the syntax right. I tried&lt;/P&gt;&lt;P&gt;//accepted records - failing&lt;BR /&gt;Count(&lt;BR /&gt;Filter($layer, "Species = '" + replace($feature.species, "'","''") + "'") &amp;amp;&amp;amp; (batch_number != Null)&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried lots of different versions using tick marks and $feature, but no luck.&lt;/P&gt;&lt;P&gt;please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2023 14:15:00 GMT</pubDate>
    <dc:creator>KurtRadamaker1</dc:creator>
    <dc:date>2023-09-21T14:15:00Z</dc:date>
    <item>
      <title>Arcade syntax</title>
      <link>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331043#M6749</link>
      <description>&lt;P&gt;In an arcade attribute expression I'm counting all of the rows in a layer using the filter. The below code is working.&lt;/P&gt;&lt;P&gt;This Arcade code correctly returns a count of all species in the layer matching the value of the species point clicked for the popup.&lt;/P&gt;&lt;P&gt;//accepted records - working correctly&lt;BR /&gt;Count(&lt;BR /&gt;Filter($layer, "Species = '" + replace($feature.species, "'","''") + "'")&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;I would also like to filter if row batch number is not null. I can't seem to get the syntax right. I tried&lt;/P&gt;&lt;P&gt;//accepted records - failing&lt;BR /&gt;Count(&lt;BR /&gt;Filter($layer, "Species = '" + replace($feature.species, "'","''") + "'") &amp;amp;&amp;amp; (batch_number != Null)&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried lots of different versions using tick marks and $feature, but no luck.&lt;/P&gt;&lt;P&gt;please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 14:15:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331043#M6749</guid>
      <dc:creator>KurtRadamaker1</dc:creator>
      <dc:date>2023-09-21T14:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade syntax</title>
      <link>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331078#M6751</link>
      <description>&lt;P&gt;I think this is what it should be (based on my shaky SQL92 knowledge)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Count(
  Filter($layer, "Species = '" + replace($feature.species, "'","''") + "' AND $feature.batch_number IS NOT Null")
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could use a &lt;A href="https://developers.arcgis.com/arcade/guide/template-literals/" target="_self"&gt;template literal&lt;/A&gt; to embed expressions without excessive quotes to make it easier to understand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Count(
  Filter($layer, `Species = '${replace($feature.species, "'","''")}' AND ${$feature.batch_number} IS NOT Null`)
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 16:20:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331078#M6751</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-09-21T16:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade syntax</title>
      <link>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331127#M6754</link>
      <description>&lt;P&gt;I tried the above examples and I get syntax errors&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expected "!", "'", "(", "+", "-", "@", "CASE", "CAST", "DATE", "EXTRACT", "FALSE", "INTERVAL", "N'", "NOT", "NULL", "POSITION", "SUBSTRING", "TIMESTAMP", "TRIM", "TRUE", "`", [ \t\n\r], [0-9], or [A-Za-z_\x80-&amp;#65535;] but "$" found.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 16:02:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331127#M6754</guid>
      <dc:creator>KurtRadamaker1</dc:creator>
      <dc:date>2023-09-21T16:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade syntax</title>
      <link>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331159#M6756</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Count(
  Filter($layer, `Species = '${replace($feature.species, "'","''")}' AND batch_number IS NOT Null`)
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 16:51:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331159#M6756</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-09-21T16:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade syntax</title>
      <link>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331218#M6757</link>
      <description>&lt;P&gt;How I solved it&lt;/P&gt;&lt;P&gt;//accepted records&lt;/P&gt;&lt;P&gt;var sp = "Species = '" + replace($feature.species, "'","''") + "'"&lt;BR /&gt;var bn = "batch_number is NOT Null"&lt;BR /&gt;Count(&lt;BR /&gt;Filter($layer, sp + ' AND ' + bn)&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No clue why the other syntax doen't work!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 18:25:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331218#M6757</guid>
      <dc:creator>KurtRadamaker1</dc:creator>
      <dc:date>2023-09-21T18:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade syntax</title>
      <link>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331222#M6758</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&amp;amp;&amp;amp;&lt;/STRONG&gt; and &lt;STRONG&gt;!=&lt;/STRONG&gt; are logical operators used in many programming languages. SQL uses more natural operators, in this case &lt;STRONG&gt;AND&lt;/STRONG&gt; and&lt;STRONG&gt; IS NOT NULL&lt;/STRONG&gt;, as Ken pointed out.&lt;/P&gt;&lt;P&gt;Instead of writing the query yourself, which quickly gets unwieldy and hard to read with all those plusses and apostrophes, you can use the&amp;nbsp;@ notation of the &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#filter" target="_blank" rel="noopener"&gt;Filter&lt;/A&gt; function:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var species = Replace($feature.species, "'", "''")
var sql = "Species = @species AND batch_number IS NOT NULL"
return Count(Filter($layer, sql))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 18:36:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/arcade-syntax/m-p/1331222#M6758</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-09-21T18:36:14Z</dc:date>
    </item>
  </channel>
</rss>

