<?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: Dashboard indicator arcade script in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1090366#M4973</link>
    <description>&lt;P&gt;A data expression expects a Featureset as a data source, so you have to do some more work when you want to return Sum. Take a look at this &lt;A href="https://community.esri.com/t5/arcgis-dashboards-questions/arcgis-dashboard-data-expression-quot-unable-to/m-p/1086577#M4915" target="_self"&gt;discussion&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Aug 2021 14:19:08 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2021-08-19T14:19:08Z</dc:date>
    <item>
      <title>Dashboard indicator arcade script</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1090340#M4972</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am new to arcade scripts&lt;/P&gt;&lt;P&gt;I want to select unique values from two columns and sum one of them&lt;/P&gt;&lt;P&gt;If I go to edit Dashboard + indicator and press new data expression the following script works:&lt;/P&gt;&lt;P&gt;var features = FeatureSetByPortalItem( Portal('&lt;A href="https://www.arcgis.com" target="_blank"&gt;https://www.arcgis.com&lt;/A&gt;'), '98cca0ba2d58470b96061faa24421e66', 0, ['ID_FCC', 'RestorationArea','RestorationType'], false );&lt;BR /&gt;var filterFeatures = Filter(features, "RestorationType &amp;lt;&amp;gt; 'Riparian'");&lt;BR /&gt;var distinctFeatures = Distinct(filterFeatures,['ID_FCC','RestorationArea']);&lt;BR /&gt;Sum(distinctFeatures, 'RestorationArea')&lt;/P&gt;&lt;P&gt;If I press done the Data expressions shows: ! Unable to execute Arcade script&lt;/P&gt;&lt;P&gt;Is there another way to implement distinct filter to an indicator?&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;P&gt;best regards&lt;/P&gt;&lt;P&gt;Adrian&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 13:33:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1090340#M4972</guid>
      <dc:creator>AdrianPatrulescu</dc:creator>
      <dc:date>2021-08-19T13:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard indicator arcade script</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1090366#M4973</link>
      <description>&lt;P&gt;A data expression expects a Featureset as a data source, so you have to do some more work when you want to return Sum. Take a look at this &lt;A href="https://community.esri.com/t5/arcgis-dashboards-questions/arcgis-dashboard-data-expression-quot-unable-to/m-p/1086577#M4915" target="_self"&gt;discussion&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 14:19:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1090366#M4973</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-08-19T14:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard indicator arcade script</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1090389#M4974</link>
      <description>&lt;P&gt;As &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt; points out, you need to get your results into a FeatureSet. This gives you two options:&lt;/P&gt;&lt;H4&gt;Populate an Empty FeatureSet&lt;/H4&gt;&lt;P&gt;Following the linked example from Ken's post, or similar examples on &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/CalculationAcrossFields.md" target="_blank"&gt;GitHub&lt;/A&gt;, you need to create a dict object and then use that Sum(...) value to populate an attribute there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var fs_dict = {
    fields: [{name: 'Sum', 'type':'esriFieldTypeDouble'}],
    geometryType: '',
    features: [{attributes: {'Sum': 0}}]
}

fs_dict['features'][0]['attributes']['Sum'] = Sum(distinctFeatures, 'RestorationArea')

return FeatureSet(Text(fs_dict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But honestly, that's &lt;EM&gt;way &lt;/EM&gt;more work than it's worth. There's a simpler way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H4&gt;Use the Indicator's Built-In Aggregation&lt;/H4&gt;&lt;P&gt;Using the same expression you've shared in your post, simply omit the &lt;STRONG&gt;Sum&lt;/STRONG&gt; and instead return the &lt;STRONG&gt;distinctFeatures&lt;/STRONG&gt; FeatureSet. Then on the indicator settings, set the &lt;STRONG&gt;Value Type&lt;/STRONG&gt; to &lt;STRONG&gt;Statistic&lt;/STRONG&gt;, set &lt;STRONG&gt;Statistic&lt;/STRONG&gt; to &lt;STRONG&gt;Sum &lt;/STRONG&gt;and select the field you want to sum.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1629384608014.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/21162i6D47C75A5C4412E0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1629384608014.png" alt="jcarlson_0-1629384608014.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;H4&gt;GroupBy?&lt;/H4&gt;&lt;P&gt;All that said, I am curious about what the Distinct function is actually doing here, since you're just returning a single sum. &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#groupby" target="_blank"&gt;GroupBy&lt;/A&gt; can group distinct values from a field and perform a statistical calculation on any number of fields, if you were looking for the sum of the area per ID.&lt;/P&gt;&lt;PRE&gt;GroupBy(filterFeatures, 'ID_FCC', { name: 'Total_Area', expression: 'RestorationArea', statistic: 'SUM' })&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 14:58:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1090389#M4974</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-08-19T14:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard indicator arcade script</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1090716#M4978</link>
      <description>&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;P&gt;Thank you for your quick response&lt;/P&gt;&lt;P&gt;Using&amp;nbsp;Indicator's Built-In Aggregation worked for me&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var features = FeatureSetByPortalItem( Portal('https://www.arcgis.com'), '98cca0ba2d58470b96061faa24421e66', 0, ['ID_FCC', 'RestorationArea','RestorationType'], false );
var filterFeatures = Filter(features, "RestorationType &amp;lt;&amp;gt; 'Riparian'");
var distinctFeatures = Distinct(filterFeatures,['ID_FCC','RestorationArea']);
return distinctFeatures&lt;/LI-CODE&gt;&lt;P&gt;And after I use sum statistic on the field 'RestorationArea'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Group by - is not my case because I want to sum only once one ID, not to&amp;nbsp;&lt;SPAN&gt;sum the area per ID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank&lt;SPAN&gt;&amp;nbsp;you again&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Adrian&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 06:59:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1090716#M4978</guid>
      <dc:creator>AdrianPatrulescu</dc:creator>
      <dc:date>2021-08-20T06:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard indicator arcade script</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1098352#M5087</link>
      <description>&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;P&gt;I have another question regarding this topic&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var features = FeatureSetByPortalItem( Portal('https://www.arcgis.com'), '98cca0ba2d58470b96061faa24421e66', 0, ['ID_FCC', 'RestorationArea','RestorationType','Project','HabitatRestored','Date'], false );
var filterFeatures = Filter(features, "RestorationType &amp;lt;&amp;gt; 'Riparian'");
var distinctFeatures = Distinct(filterFeatures,['ID_FCC','RestorationArea']);
return distinctFeatures&lt;/LI-CODE&gt;&lt;P&gt;The above feature set return only ID_FCC&amp;nbsp; and RestorationArea columns together with ROW_ID&lt;/P&gt;&lt;P&gt;But I want to return also the fields from FeatureSetByPortalItem&lt;/P&gt;&lt;P&gt;Apparently Distinct Function remove other columns&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to rejoin all the fields base on ROW_ID?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Adrian&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 08:54:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-indicator-arcade-script/m-p/1098352#M5087</guid>
      <dc:creator>AdrianPatrulescu</dc:creator>
      <dc:date>2021-09-15T08:54:13Z</dc:date>
    </item>
  </channel>
</rss>

