Use arcade in dashboard Indicators to perform a math function like sum, on multiple fields for all records in a feature layer

4037
7
04-16-2020 09:49 AM
Status: Already Offered
JoeSegretto
New Contributor II

With the new ArcGIS Dashboards Beta, arcade is now available, but in a limited way.  When enabling arcade on infographic using the statistic option, the only global variable I have access to is a result of the same operator and field selection in the standard infographic widget.  So If I choose statistic and select SUM on FIELD_1, I get the global variable $datastore[sum_FIELD1].  I need to have access to the globals for all fields FIELD_1, FIELD_2...FIELD_n.  Ideally, I would have access to any statistic on any field in my globals, allowing me to create more versatile expressions in my widget. 

7 Comments
ScottKiley

This is exactly what we need as well.

Specifically the ability to do this:

                  var calcsum = sum($layer,($datapoint["attribute1"] * $datapoint["attribute2"]))

 

According to John Solly, the Dashboard uses a subset of Arcade without access to all capabilities of the Arcade language. It would be ideal if the entire Arcade library was available to the dashboard. In particular being able to use the $layer global along with the sum function would allow us to achieve much more meaningful data representations, which should be the true power of the dashboard. 

KevinMayall

Here is my use case.  We have street lights whose attributes include the wattage of a bulb and the number of bulbs. I can use Arcade in a web map pop-up to calculate, for each street light, total wattage = bulbwattage * numbulbs.

In my beta dashboard, I can include an indicator with the sum of the number of lights or the number of bulbs, but not accurately calculate the total wattage of the system .... sum(bulbWattage * numBulbs).  It is a statistic of a feature calculation.

SarahHartholt

I am hoping to do the exact same thing.

JohnNergeBrooklynPark

Just echoing my support to do what people already described. Would love to be able to use a point layer to make a list that shows count by geographic area dynamically.

If we could use the $layer global then we could get counts by an attribute quite easily.

Count(Filter($layer, "Neighborhood = '" + $feature.Neighborhood+ "'"))

This would be extra nice because then if we have other filters that update the point layer, say by date, the counts in the list would update too.

AllenovDmitriy

The GroupBy function is vital for the List widget options. Otherwise, it doesn't make sense in many cases.

PamBond1

So bummed to find out you could not use Attribute Expressions (or Arcade to create Attribute Expressions) in Dashboards.  Currently, I am looking to just do some simple addition of values from multiple fields ($feature["FieldA"]+$feature["FieldB"]+$feature["FieldC"]).  If Dashboards had access to the full suite of Arcade functionality, it would really up its game!  I looks like the only alternative for me is to run these calculations on the backend with a Python script (I don't want to have to manually make these calculations).

patrickb
Status changed to: Already Offered

The ability to do something like this is provided with data expressions (available in ArcGIS Online and in a future release of ArcGIS Enterprise). The following summarizes across two fields while grouping by another. 

var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '037799cbec1b40f2b1aa03c23b1cc91e', 0, ["*"], false);
return GroupBy(fs, ['STR_FLD'], [{ name: 'SUM_FLD', expression: 'VAL_FLD * VAL_FLD2', statistic: 'SUM' }]);  

 

Some more examples here.