If Statement/ When Statement in Arcade

576
2
12-10-2020 03:10 PM
Labels (2)
LydiaBarnard
New Contributor

Hi! I have added several layers to my map but want to change the values to 1-5 rather than having ranges such as 16-134, I have tried:

var density = $layer.Median
var ranking = When(density <=604 && density >= 605, '1',
density >=429 && density < 1604,'2',
density >= 278 && density <= 428, '3',
density >= 134 && density <= 278, '4',
density <16 && density >= 134, '5', 'na')

but recieve the error "Runtime Error: Cannot call member property on object of this type. Median"

I have also tried IIF statements but that also did not work. Any advice? thanks!

0 Kudos
2 Replies
JoshuaBixby
MVP Esteemed Contributor

The error indicates your problem is happening on the first line, so it doesn't really matter what you have after that line.

XanderBakker
Esri Esteemed Contributor

Hi @LydiaBarnard ,

 

As @JoshuaBixby  mentioned, the problem is with using the median on a layer. 

 

From your question I am deducing that you want to change the symbology. Is that correct? If so, you don't have access to the $layer and the $layer does not have a median. For symbology, you only have access to the current feature and not all the features in the layer.

In the pop-up you can access the layer and do statistics on the layer, but there is no Median function. There is a Mean function: https://developers.arcgis.com/arcade/function-reference/math_functions/#mean