<?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 data expression resulting in Nan when summed in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-data-expression-resulting-in-nan-when/m-p/1237662#M49161</link>
    <description>&lt;P&gt;I am trying to return the sum of integer fields in a layer, however, am getting a NaN result. I have tried with Count and the correct number appears, so why does Sum not work? What am I missing here?&lt;/P&gt;&lt;P&gt;I am using this in a data expression to use in Dashboards list widget. Any pointers are greatly appreciated!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var features = FeatureSetByPortalItem(
  Portal('https://adcgis.maps.arcgis.com'),
  '91feaa24f7d34f9299f5b99cbd7328ed',
  1,
  ["C18_Indst_URAdr_AgriForestFish"],
  false
);
Sum(features);&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;&lt;P&gt;&amp;nbsp;&lt;/P&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;&lt;LI-CODE lang="c"&gt;Result	Value
Result	NaN
Type	Number&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>Mon, 05 Dec 2022 03:49:47 GMT</pubDate>
    <dc:creator>Hayley</dc:creator>
    <dc:date>2022-12-05T03:49:47Z</dc:date>
    <item>
      <title>Arcade data expression resulting in Nan when summed</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-data-expression-resulting-in-nan-when/m-p/1237662#M49161</link>
      <description>&lt;P&gt;I am trying to return the sum of integer fields in a layer, however, am getting a NaN result. I have tried with Count and the correct number appears, so why does Sum not work? What am I missing here?&lt;/P&gt;&lt;P&gt;I am using this in a data expression to use in Dashboards list widget. Any pointers are greatly appreciated!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var features = FeatureSetByPortalItem(
  Portal('https://adcgis.maps.arcgis.com'),
  '91feaa24f7d34f9299f5b99cbd7328ed',
  1,
  ["C18_Indst_URAdr_AgriForestFish"],
  false
);
Sum(features);&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;&lt;P&gt;&amp;nbsp;&lt;/P&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;&lt;LI-CODE lang="c"&gt;Result	Value
Result	NaN
Type	Number&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>Mon, 05 Dec 2022 03:49:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-data-expression-resulting-in-nan-when/m-p/1237662#M49161</guid>
      <dc:creator>Hayley</dc:creator>
      <dc:date>2022-12-05T03:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade data expression resulting in Nan when summed</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-data-expression-resulting-in-nan-when/m-p/1237783#M49171</link>
      <description>&lt;P&gt;When you use the &lt;STRONG&gt;Sum &lt;/STRONG&gt;function with a single parameter, it expects an &lt;EM&gt;array &lt;/EM&gt;of summable values.&lt;/P&gt;&lt;P&gt;When you're using a &lt;EM&gt;FeatureSet&lt;/EM&gt;, you need to supply a second parameter with the field name you want summed, as there could be any number of fields in a FeatureSet. Even when you only specify a single field, it will likely still have an ObjectID field, so it needs to be told which field you want.&lt;/P&gt;&lt;P&gt;Try &lt;STRONG&gt;Sum(features, 'C18_Indst_URAdr_AgriForestFish')&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 15:05:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-data-expression-resulting-in-nan-when/m-p/1237783#M49171</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-12-05T15:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade data expression resulting in Nan when summed</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-data-expression-resulting-in-nan-when/m-p/1237943#M49183</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;, thanks for explaining!&lt;/P&gt;&lt;P&gt;The expression now results in the correct number:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var features = FeatureSetByPortalItem(
  Portal('https://adcgis.maps.arcgis.com'),
  '91feaa24f7d34f9299f5b99cbd7328ed',
  1,
  ["C18_Indst_URAdr_AgriForestFish"],
  false
);
return(Sum(features, 'C18_Indst_URAdr_AgriForestFish'))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However in dashboards it says the Arcade expression is unable to be executed? How do I enable it to be used in my widgets?&lt;/P&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="Hayley_0-1670268856681.png" style="width: 729px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/57671i9EF01A420AA1CE37/image-dimensions/729x70?v=v2" width="729" height="70" role="button" title="Hayley_0-1670268856681.png" alt="Hayley_0-1670268856681.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 19:35:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-data-expression-resulting-in-nan-when/m-p/1237943#M49183</guid>
      <dc:creator>Hayley</dc:creator>
      <dc:date>2022-12-05T19:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade data expression resulting in Nan when summed</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-data-expression-resulting-in-nan-when/m-p/1237969#M49185</link>
      <description>&lt;P&gt;Oh, I'm sorry! I thought this was an Advanced Formatting thing, I missed the part about it being a Data Expression. A Data Expression needs a &lt;EM&gt;FeatureSet&lt;/EM&gt; as its output.&lt;/P&gt;&lt;P&gt;You could write this up as a Data Expression easily enough, but can I ask how you're using the data in your dashboard? If all you need is the number, you could get that into something like an Indicator widget without needing a separate expression.&lt;/P&gt;&lt;P&gt;In any case, the easiest way to get an output FeatureSet is to use GroupBy, which can handle the aggregation for you, too.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var features = FeatureSetByPortalItem(
  Portal('https://adcgis.maps.arcgis.com'),
  '91feaa24f7d34f9299f5b99cbd7328ed',
  1,
  ["C18_Indst_URAdr_AgriForestFish"],
  false
);

return GroupBy(
    features,
    {name: 'id', expression: '1'},
    {name: 'the_sum', expression: 'C18_Indst_URAdr_AgriForestFish', statistic: 'SUM'}
)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 05 Dec 2022 20:11:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-data-expression-resulting-in-nan-when/m-p/1237969#M49185</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-12-05T20:11:46Z</dc:date>
    </item>
  </channel>
</rss>

