I'm trying to generate fields that will tell field crews a replacement cost per feature and the current total cost of the replacement program based on the work they are doing. I was expecting the scenario below to work but it does not. Is it possible to call other Arcade expression in other expressions?
For the individual feature's replacement cost: Expression1= (Length*Width)*[StaticMonetaryAmount]
For the total program replacements cost: Expression2 = SUM($layer,'Expression1')
in Map Viewer Classic, open the table and left click on the column header. Select Calculate from the popup and then choose from one of the functions on the right.
In short, no, it is not possible to reference one expression from another. You'll need to calculate the sum entirely on its own.
This was my fear. When I attempt to run the entire sum on its own using the $layer parameter, I'm getting values that are doubled. Here is my attempt at the two different fields and their expression. When I sum the first field (Individual Features' replacement cost) I don't get the same value as the second field shows. It essentially doubles each time.
###Individual Features Replacement Cost###
Var PatchingAreaInYds = ($feature.WIDTH * $feature.LENGTH)/9
PatchingArea*26
##Summarizing All Features Replacement Cost###
Var ASPHALTLENGTH =sum($layer,'LENGTH')
Var ASPHALTWIDTH =sum($layer,'WIDTH')
Var PATCHINGAREAINYDS =(ASPHALTLENGTH*ASPHALTWIDTH)/9
PATCHINGAREAINYDS*26
you obviously won't sum Longitude but this is the idea and how it appears for me
Thanks for the screenshots this was helpful for me to explore into. This appears to be for only hosted data layers. Also I think this is AGOL's version of Field Calculator which you wouldn't be able to run on a field created using an Arcade Expressions.