<?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 3.0.3 - Invalid Arcade Syntax for Attribute Rule? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260389#M65805</link>
    <description>&lt;P&gt;You said that $feature.Date is a double. You compare it to a string. Your condition will always be true, so the else block will never be entered.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Feb 2023 09:23:26 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-02-22T09:23:26Z</dc:date>
    <item>
      <title>ArcGIS Pro 3.0.3 - Invalid Arcade Syntax for Attribute Rule?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260103#M65761</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In ArcGIS Pro, I am trying to implement a simple Attribute Rule calculation in Arcade and I am stuck with syntax! I am filtering the current features with an SQL type query and Arcade returns an invalid where clause...&lt;/P&gt;&lt;P&gt;In practice, this Filter function should return a unique feature with which I am performing a growth calculation on the current feature.&lt;/P&gt;&lt;P&gt;Any guess?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Invalid_Arcade_expression_Builder2.png" style="width: 831px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63306i7E9354E19A9A2B80/image-size/large?v=v2&amp;amp;px=999" role="button" title="Invalid_Arcade_expression_Builder2.png" alt="Invalid_Arcade_expression_Builder2.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 16:43:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260103#M65761</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-02-21T16:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.0.3 - Invalid Arcade Syntax for Attribute Rule?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260106#M65762</link>
      <description>&lt;P&gt;To post code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1674589814049.png" style="width: 546px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61109iE6E36886309482F5/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1674589814049.png" alt="JohannesLindner_0-1674589814049.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1674589827880.png" style="width: 477px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61110i9AA607855960C6E3/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1674589827880.png" alt="JohannesLindner_1-1674589827880.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While many programming languages use the operator &amp;amp;&amp;amp; as logical and, SQL uses "AND". So your query in line 4 should be&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;"date = @startDate AND census = @census"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, you're missing a null check after line 4. If the Filter function returns an empty featureset (nothing found with this query), First() will return null, and then you'll get an error in line 6, when you call null.SomeField&lt;/P&gt;&lt;P&gt;After line 5, insert something like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if(dic == null) { return '0' }  // I guess this is your default value, judging from line 9&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 21 Feb 2023 16:54:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260106#M65762</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-21T16:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.0.3 - Invalid Arcade Syntax for Attribute Rule?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260107#M65763</link>
      <description>&lt;P&gt;You can't pass an Arcade operator, &amp;amp;&amp;amp;, in a SQL statement because whatever is processing the SQL has no clue how to handle &amp;amp;&amp;amp;.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 16:55:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260107#M65763</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2023-02-21T16:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.0.3 - Invalid Arcade Syntax for Attribute Rule?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260111#M65765</link>
      <description>&lt;P&gt;Thanks. I already tried the proper 'SQL' like AND, but still no luck!&lt;/P&gt;&lt;P&gt;I included your 'null' logic to safeguard my Arcade code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if($feature.Date != '2019'){
  var census = Text($feature.census);
  var startDate = '2019';
  var features = Filter($featureSet, "date = @startDate AND census = @census");
  var featureFirst = First(features);
  if(dic == null){
    return '0'} else {
    var growth = (($feature.Totals_by_Tract_by_Sector/featureFirst.Totals_by_Tract_by_Sector)-1)*100;
  }
} else {
  return '0'
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Invalid_Arcade_expression_Builder_AND.png" style="width: 372px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63307i4AFB6B375AE65E22/image-size/large?v=v2&amp;amp;px=999" role="button" title="Invalid_Arcade_expression_Builder_AND.png" alt="Invalid_Arcade_expression_Builder_AND.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 17:03:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260111#M65765</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-02-21T17:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.0.3 - Invalid Arcade Syntax for Attribute Rule?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260123#M65769</link>
      <description>&lt;P&gt;What field types are date and census?&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// invert your condition and return the default value early.
// that makes the following code easier to follow, because
// you don't need the extra else block
if($feature.Date == 2019){
    return '0'
}
var census = $feature.census; // take the "pure" value instead of Text()
var startDate = 2019;
var features = Filter($featureSet, "date = @startDate AND census = @census");
var featureFirst = First(features);
if(featureFirst == null){
    return '0'
}
var growth = (($feature.Totals_by_Tract_by_Sector/featureFirst.Totals_by_Tract_by_Sector)-1)*100;
return growth&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 18:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260123#M65769</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-21T18:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.0.3 - Invalid Arcade Syntax for Attribute Rule?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260143#M65771</link>
      <description>&lt;P&gt;In your other answer, Arcade is complaining about census being empty. To solve that, replace line 4 in the script above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if($feature.Date == 2019 || IsEmpty($feature.census)){
    return '0'
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 18:44:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260143#M65771</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-21T18:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.0.3 - Invalid Arcade Syntax for Attribute Rule?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260379#M65803</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Really nice, it works and I like the 'inverted' logic to avoid the else statment.&lt;/P&gt;&lt;P&gt;Moreover, I have a similar Arcade code and it never go to the else statment!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if($feature.Date != '2019'){
  var census = ($feature.census);
  var startDate = 2019;
  var features = Filter($featureSet, "date = " + startDate + " AND census = " + census);
  var featureFirst = First(features);
  if(features != null){
    var growth = (($feature.Totals_by_Tract_by_Sector/featureFirst.Totals_by_Tract_by_Sector)-1)*100;
  }
  return growth;
} else {
  return '99';
}&lt;/LI-CODE&gt;&lt;P&gt;Strange&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 09:02:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260379#M65803</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-02-22T09:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.0.3 - Invalid Arcade Syntax for Attribute Rule?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260389#M65805</link>
      <description>&lt;P&gt;You said that $feature.Date is a double. You compare it to a string. Your condition will always be true, so the else block will never be entered.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 09:23:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-0-3-invalid-arcade-syntax-for/m-p/1260389#M65805</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-22T09:23:26Z</dc:date>
    </item>
  </channel>
</rss>

