Select to view content in your preferred language

How do I find the max value of all features?

4485
4
Jump to solution
06-14-2020 03:02 PM
TysonM
by
Emerging Contributor

I thought Arcade was supported by all ESRI products, but I can't use the $layer prefiix to find the max value across all records in my layer.

In ArcGIS Online, it's very easy to do, but Pro does not recognize $layer at all. Why doesn't Arcade for Pro work like the online version?

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Tyson TM ,

When you calculate a field in ArcGIS Pro you have access to the FeatureSetBy* functions which you can use to access the featureset and use it in the Min and Max functions of Arcade.

Before:

After:

Arcade expression:

var fs = FeatureSetByName($datastore, "BojacaRNI_puntos");
return 1/ (MAX(fs, "CampoEM") - MIN(fs, "CampoEM"));

You can use either $datastore with the name of the featureclass or $map with the name in the TOC. Remember that the Min and Max functions take two parameters (the featureset and the fieldname).

View solution in original post

4 Replies
DanPatterson
MVP Esteemed Contributor

Not all is applicable to all products yet.

Getting Started | ArcGIS for Developers 

Arcade Function Reference | ArcGIS for Developers 


... sort of retired...
0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Can you elaborate on how exactly you are trying to use Arcade in Pro?  What part of Pro (Field Calculator, Labeling, etc...) are you trying your code?

0 Kudos
TysonM
by
Emerging Contributor

I'm using the Calendar Heat Map Chart to track events that have occurred over a 20 year span. Currently the chart aggregates all of the events by day of the year. Instead of counting each event a whole unit, I need to average it by year.

I attempted to create a calculated field that would hold a value that is the inverse of the number of years, to effectively get a per year average. My plan was to simply have Arcade take the difference between the MAX and MIN year value, and divide 1 by it. E.G. 1/ (MAX($layer.Year)-MIN($layer.Year)). I could then use this field in the Calendar Heat Map to average out the events per day.

Since the events range from early 2000 to present day, I need to calculate the MAX and MIN down the entire table, not just by row/record/feature, which is how Arcade works in Pro. There is no $layer option like there is in the Online version. Now, I can certainly just enter in .05 and call it good. But I don't want to have to update this every year.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Tyson TM ,

When you calculate a field in ArcGIS Pro you have access to the FeatureSetBy* functions which you can use to access the featureset and use it in the Min and Max functions of Arcade.

Before:

After:

Arcade expression:

var fs = FeatureSetByName($datastore, "BojacaRNI_puntos");
return 1/ (MAX(fs, "CampoEM") - MIN(fs, "CampoEM"));

You can use either $datastore with the name of the featureclass or $map with the name in the TOC. Remember that the Min and Max functions take two parameters (the featureset and the fieldname).