Select to view content in your preferred language

Arcade expression to decode values

4807
4
Jump to solution
07-17-2018 08:45 AM
AndrewL
Frequent Contributor

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.

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

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

View solution in original post

4 Replies
KenBuja
MVP Esteemed Contributor

What are the values that are possible for dn? Can you share that service or provide a list of some of the values?

0 Kudos
AndrewL
Frequent Contributor

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.

0 Kudos
KenBuja
MVP Esteemed Contributor

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
AndrewL
Frequent Contributor

Great! Thanks, that worked.

0 Kudos