I am trying to use an Arcade expression to display coded values in a popup in ArcGIS Online, but it is not working. I am using the code from the decode example. It does not display in the popup. No error message is given in the popup.
var code = $feature.dn;
var decodedValue = Decode(code, 2, 'Non-Severe', 3, 'Marginal', 4, 'Slight', 'Other');
I am not the author of the map service. The dn field is an esriFieldTypeDouble. Thank you.
Solved! Go to Solution.
You needed to state what value to return. See the documentation about this.
var code = $feature.dn;
var decodedValue = Decode(code, 2, 'Non-Severe', 3, 'Marginal', 4, 'Slight', 'Other');
decodedValue; //return decodedValue; also works
or it could be a single line expression.
Decode($feature.dn, 2, 'Non-Severe', 3, 'Marginal', 4, 'Slight', 'Other');
// return Decode($feature.dn, 2, 'Non-Severe', 3, 'Marginal', 4, 'Slight', 'Other'); to be more explicit
What are the values that are possible for dn? Can you share that service or provide a list of some of the values?
Sure it is a public service from NWS: Layer: Day 1 Convective Outlook (ID: 1)
Possible values are 2, 3, 4, 5, 6, and 7.
You needed to state what value to return. See the documentation about this.
var code = $feature.dn;
var decodedValue = Decode(code, 2, 'Non-Severe', 3, 'Marginal', 4, 'Slight', 'Other');
decodedValue; //return decodedValue; also works
or it could be a single line expression.
Decode($feature.dn, 2, 'Non-Severe', 3, 'Marginal', 4, 'Slight', 'Other');
// return Decode($feature.dn, 2, 'Non-Severe', 3, 'Marginal', 4, 'Slight', 'Other'); to be more explicit
Great! Thanks, that worked.