<?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 Expression using Distinct fails in SDE, not File GDB in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-using-distinct-fails-in-sde-not/m-p/1536966#M1573</link>
    <description>&lt;P&gt;Hello - I am putting together a relatively simple&amp;nbsp; Arcade script to eventually function as an attribute rule in order to create an identifier in a building footprint polygon by using a combination of an address number and unit number from address point layer.&lt;/P&gt;&lt;P&gt;The following works just fine in a file geodatabase, where $feature is my building footprint layer&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var Address = FeatureSetByName($datastore, 'TRANS.AddressPoints', ['AddNumber', 'UnitNumber'],false); //, 'bldgname'
var intAddress = Intersects($feature, Address); //, 'bldgname'

var addNums = Distinct(intAddress, ['AddNumber']); // always 1 or gt 1
var untNums = Distinct(intAddress , ['UnitNumber']); // always 1 or gt 1, when 1 just use add number

var addCnt = Count(AddNums);
var untCnt = Count(untNums);
Console(addCnt);
Console(untCnt);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I run this against our current SQL2022 SDE instance to test a calculation in the Field Calculator (upgraded with the latest Pro 3.3.1 internals), it can't get past line 7, because it can't return a DISTINCT"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Invalid expression.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Error on line 7.&lt;/STRONG&gt;&lt;STRONG&gt;Underlying DBMS error [[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]The geometry data type cannot be selected as DISTINCT because it is not comparable.] [TRANS.AddressPoints][STATE_ID = 0]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have to have a distinct array of values for both address number and unit number because they can repeat within a given footprint.&amp;nbsp; Any ideas?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/601547"&gt;@rlyding&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Sep 2024 17:17:54 GMT</pubDate>
    <dc:creator>DavidColey</dc:creator>
    <dc:date>2024-09-10T17:17:54Z</dc:date>
    <item>
      <title>Arcade Expression using Distinct fails in SDE, not File GDB</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-using-distinct-fails-in-sde-not/m-p/1536966#M1573</link>
      <description>&lt;P&gt;Hello - I am putting together a relatively simple&amp;nbsp; Arcade script to eventually function as an attribute rule in order to create an identifier in a building footprint polygon by using a combination of an address number and unit number from address point layer.&lt;/P&gt;&lt;P&gt;The following works just fine in a file geodatabase, where $feature is my building footprint layer&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var Address = FeatureSetByName($datastore, 'TRANS.AddressPoints', ['AddNumber', 'UnitNumber'],false); //, 'bldgname'
var intAddress = Intersects($feature, Address); //, 'bldgname'

var addNums = Distinct(intAddress, ['AddNumber']); // always 1 or gt 1
var untNums = Distinct(intAddress , ['UnitNumber']); // always 1 or gt 1, when 1 just use add number

var addCnt = Count(AddNums);
var untCnt = Count(untNums);
Console(addCnt);
Console(untCnt);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I run this against our current SQL2022 SDE instance to test a calculation in the Field Calculator (upgraded with the latest Pro 3.3.1 internals), it can't get past line 7, because it can't return a DISTINCT"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Invalid expression.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Error on line 7.&lt;/STRONG&gt;&lt;STRONG&gt;Underlying DBMS error [[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]The geometry data type cannot be selected as DISTINCT because it is not comparable.] [TRANS.AddressPoints][STATE_ID = 0]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have to have a distinct array of values for both address number and unit number because they can repeat within a given footprint.&amp;nbsp; Any ideas?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/601547"&gt;@rlyding&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 17:17:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-using-distinct-fails-in-sde-not/m-p/1536966#M1573</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2024-09-10T17:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression using Distinct fails in SDE, not File GDB</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-using-distinct-fails-in-sde-not/m-p/1537076#M1574</link>
      <description>&lt;P&gt;Ok so for whatever reason, the DISTINCT function is a constraint when trying to operate against SQL geometry.&amp;nbsp; Working with my collegue, this works against an SDE layer:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var Address = FeatureSetByName($datastore, 'TRANS.AddressPoints', ['AddNumber', 'UnitNumber'],false);
var intAddress = Intersects($feature, Address); //, 'bldgname'
var addNums = [];
for (var i in intAddress){
   //console(i);
    Push(addNums, i['AddNumber']);
}
addNums = Sort(Distinct(addNums));
console(addNums);
var addCnt = Count(addNums);
Console(addCnt);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By setting up an array first to store the Intersects return, and then passing the initial array into a sorted array, the DISTINCT function works or rather validates in the field calculator.&lt;/P&gt;&lt;P&gt;So I think I basically answered my own question.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/456188"&gt;@mstranovsky&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/601547"&gt;@rlyding&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 20:16:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/arcade-expression-using-distinct-fails-in-sde-not/m-p/1537076#M1574</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2024-09-10T20:16:19Z</dc:date>
    </item>
  </channel>
</rss>

