I am using ArcGIS Pro 2.5 and I am trying to calculate the sum of a field in Arcade. I used
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
I am assuming that you are using the Field Calculator based on your question.
$layer is certainly present in Pro 2.5, and is included in the Field Calculate profile of Arcade. The code you give in your post should work just fine, as pictured below. I used the Arcade Playground to test it.
According to the Esri docs, the current Field Calculate profile has been in place since Arcade v 1.5, which would have been back in Pro 2.3, so I don't think the Pro version is causing your problem.
It's also possible you're not using the Field Calculator, but are trying to sum a field for use in another Arcade profile, such as generating popup content, symbology, or labels. In some cases, the
$layer global is not accessible. You should refer to the other profiles in the doc link above to see which globals are available to your particular situation.