Mean for all values Portal/Arcade

374
7
06-26-2019 09:01 AM
JoeBorgione
MVP Esteemed Contributor

Yesterday, I posted https://community.esri.com/thread/235847-mean-for-all-features-not-just-one-arcade and I was able to find the solution I was after, in ArcPro.  But apparently, using $layer is not supported in Portal.

From yesterdays post: I have a polygon feature class representing Meals on Wheels data by month/zipcode: imagine a 'stacked' set of polygons.  When I identify a given zipcode polygon, the pop up returns 12 values (one per month).  That's fine but I'd like to show the mean of all 12 months.  

I published the data to our internal portal but now when I try to use the same approach as in PRO, I get an error:

Some day I'll get a grasp on Arcade and what it can do, and where, and when...

Xander Bakker

That should just about do it....
Tags (1)
0 Kudos
7 Replies
XanderBakker
Esri Esteemed Contributor

What version of Enterprise do you have?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi jborgion , 

As a side note...

Have a look at the different Arcade expression profiles. (I took these from https://developers.arcgis.com/arcade/playground/ )

# Alias
- will only provide access to the $value

# Attribute Rules (Calculation, Constraint and Validation)
- $feature and $datastore (so you can acccess other layers and features)
- no access to Attachments and FeatureSetByPortalItem

# Constraint
- access to Feature attributes and geometry
- no access to Attachments, FeatureSet*, Filter and OrderBy

# Feature Z
- access to Feature attributes and geometry
- no access to Attachments, FeatureSet*, Filter and OrderBy

# Field Calculate
- access to $feature, $datastore and $layer
- access to Attachments, FeatureSet*, Filter, OrderBy and all other functions

# Labeling
- access to Feature attributes and geometry
- no access to Attachments, FeatureSet*, Filter and OrderBy

# Popup
- access to $feature, $datastore, $map and $layer
- no access to Attachments and FeatureSetByPortalItem

# Visualization
- access to Feature attributes, geometry and $view.scale
- no access to Attachments, FeatureSet*, Filter and OrderBy


Functionality will depend on version of the software (Pro and Portal in Enterprise). As far as I can deduce the Arcade functionality will first appear in ArcGIS Online, then in Pro and lastly in Enterprise. Some things are currently only available in Pro (like Attribute Rules and this requires using an Enterprise Geodatabase).

JoeBorgione
MVP Esteemed Contributor

10.6.1

From your post above....

# Popup
- access to $feature, $datastore, $map and $layer
- no access to Attachments and FeatureSetByPortalItem

rats....

That should just about do it....
0 Kudos
XanderBakker
Esri Esteemed Contributor

I think in 10.6.1 you should have access to FeatureSetBy functions (you can still use the $map and $datastore to access the layer). So the fact that the FeatureSetByPortalItem is not available should not be a restriction. Wait.. the FeatureSetBy* functions were introduced in AGOL in december 2018, so they were not available until this April in Enterprise. So probably not available 10.6.1

The easiest way to check this is to enter the pop-up configuration of a layer in your web map and in the Arcade expression window you will see which functions are available and which are not. FeatureSetByPortalItem  is just another way of accessing an item, but it is not the only way to do that.

JoeBorgione
MVP Esteemed Contributor

I've been looking at the $map and $datastore global variables, but I don't see an actual syntax on how to use them.  Here is one situation I'd like to solve:  I need the ratio of  attributes from two different layers:

FeatureLayer_1, Attribute_1 divided by FeatureLayer_2, Attribute_2

That should just about do it....
0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Joe Borgione , 

The fact that the formula requires access to 2 layers, this would need the FeatureSetBy function to do so. And this is not available in Enterprise 10.6.1. When are you planning to update your Enterprise? 10.7.1 is almost available...

JoeBorgione
MVP Esteemed Contributor

We just barely upgraded to 10.6.1, and our SOP is current version - 1, so it won't be for a while.  Thanks for your help none-the-less Xander!

That should just about do it....