Select to view content in your preferred language

Restricting Query in Arcade

589
1
Jump to solution
06-02-2022 08:14 AM
Labels (3)
SeanDugan
New Contributor

HI there,

I've got a feature layer (78,000 rows), and in a few columns I need to do some replacing. There are "A", "B", "B1", "B2", "C" and "D" values. I need to replace every "B" to a "B1". I've opened up the feature layer in ArcGIS online, and gone to the data tab. The I click on the column header, and hit calculate. I'm, then going into arcade and writing the following;

Replace($feature.Birds, 'B', 'B1')

This does replace all the B's, but unfortunately the "B1" values become "B11", and "B2" becomes "B12". Is there a way to restrict it so that it will only replace the lone B values, not when they're in a B1 or B2? I'm just getting started with this, and my knowledge of the syntax isn't great.

Any help would be appreciated!

1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You can test whether the value is "B" then replace it.

if ($feature.Birds == 'B') {
  Replace($feature.Birds, 'B', 'B1')
}

View solution in original post

1 Reply
KenBuja
MVP Esteemed Contributor

You can test whether the value is "B" then replace it.

if ($feature.Birds == 'B') {
  Replace($feature.Birds, 'B', 'B1')
}