<?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 Issue Using Average or Mean in an Attribute Rule in Geodatabase Questions</title>
    <link>https://community.esri.com/t5/geodatabase-questions/arcade-issue-using-average-or-mean-in-an-attribute/m-p/777997#M1447</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having trouble using the Average and Mean function in an attribute rule.&amp;nbsp; I am intersecting points with a polygon being inserted/updated and wish to get the average of a field value from all intersecting points.&amp;nbsp; I am able to use the Sum and Count functions just find and my current workaround is to use both to get the Average.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I use Average or Mean, I first got an error about how the field name was used to run the function.&amp;nbsp; I was able to fix that by calling it differently (you can see the difference in the expression below).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error I am getting now is below.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/475224_pastedImage_4.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Arcade expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;var cpm_field = "Counts_Per_Minute"
var fsGS = FeatureSetbyName($datastore, "sde.blah.Gamma_Survey",[cpm_field],true)
var fsGSIntersect = Intersects(fsGS ,$feature)
&amp;nbsp;
var result_avg = null
&amp;nbsp;
if (Count(fsGSIntersect) == 0)
&amp;nbsp;&amp;nbsp; return result_avg ;
else
&amp;nbsp;&amp;nbsp; //result_avg =&amp;nbsp; Sum(fsGSIntersect,cpm_field)/Count(fsGSIntersect) My workaround
   //result_avg =&amp;nbsp; Mean(fsGSIntersect,cpm_field) Does not work
&amp;nbsp;&amp;nbsp; result_avg =&amp;nbsp; Mean(fsGSIntersect,fsGSIntersect[cpm_field])
&amp;nbsp;
return result_avg ;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 08:45:22 GMT</pubDate>
    <dc:creator>MichaelBrown4</dc:creator>
    <dc:date>2021-12-12T08:45:22Z</dc:date>
    <item>
      <title>Arcade Issue Using Average or Mean in an Attribute Rule</title>
      <link>https://community.esri.com/t5/geodatabase-questions/arcade-issue-using-average-or-mean-in-an-attribute/m-p/777997#M1447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having trouble using the Average and Mean function in an attribute rule.&amp;nbsp; I am intersecting points with a polygon being inserted/updated and wish to get the average of a field value from all intersecting points.&amp;nbsp; I am able to use the Sum and Count functions just find and my current workaround is to use both to get the Average.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I use Average or Mean, I first got an error about how the field name was used to run the function.&amp;nbsp; I was able to fix that by calling it differently (you can see the difference in the expression below).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error I am getting now is below.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/475224_pastedImage_4.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Arcade expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;var cpm_field = "Counts_Per_Minute"
var fsGS = FeatureSetbyName($datastore, "sde.blah.Gamma_Survey",[cpm_field],true)
var fsGSIntersect = Intersects(fsGS ,$feature)
&amp;nbsp;
var result_avg = null
&amp;nbsp;
if (Count(fsGSIntersect) == 0)
&amp;nbsp;&amp;nbsp; return result_avg ;
else
&amp;nbsp;&amp;nbsp; //result_avg =&amp;nbsp; Sum(fsGSIntersect,cpm_field)/Count(fsGSIntersect) My workaround
   //result_avg =&amp;nbsp; Mean(fsGSIntersect,cpm_field) Does not work
&amp;nbsp;&amp;nbsp; result_avg =&amp;nbsp; Mean(fsGSIntersect,fsGSIntersect[cpm_field])
&amp;nbsp;
return result_avg ;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:45:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/arcade-issue-using-average-or-mean-in-an-attribute/m-p/777997#M1447</guid>
      <dc:creator>MichaelBrown4</dc:creator>
      <dc:date>2021-12-12T08:45:22Z</dc:date>
    </item>
  </channel>
</rss>

