3

I'm tasked with building an Arcade expression that evaluates whether a string field includes given characters, and returns values accordingly. Attribute UTILITY_GROUP may be E, EU, G, or GU. To cut down on the number of comparisons required, I had hoped to do something like (pseudocode):

var utility = $feature.UTILITY_GROUP
if ('E' in utility) {
  return 'electric'
}
if ('G' in utility) {
  return 'gas'
}

Is there a way to express "if string includes [character]" in Arcade? I didn't see anything documented in the logical operators.

0
3

I've just done a quick test in ArcGIS Pro 2.1. A Find('text to find', 'text to search in', 0) seems to work. I've only tested on a handful of features, so I'm not sure what performance is like in a large dataset.

var utility = $feature.UTILITY_GROUP;
if (Find('E', utility, 0) > 0) {
  return 'electric'
  };
if (Find('G', utility, 0) > 0) {
  return 'gas'
  };

See ArcGIS Arcade - Text Functions - Find

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.