Arcade expression to display just the numbers of an address field

277
2
Jump to solution
03-01-2021 08:32 AM
Labels (2)
KimberlyRieger
New Contributor II

Hello! Is there an Arcade function I can use that will display in the labels just the numbers in an address field? The address field that I have on a particular layer has the number and street name together. The labels I want to create for that layer just need the address number displayed. Thank you.

1 Solution

Accepted Solutions
jcarlson
Regular Contributor II

I don't know what your address data looks like, but assuming there's a space between the numbers and the street name, you could try using Split.

var addr = '1223 S Main St'

return Split(addr, ' ', 1)[0]

By including the limit argument, the function stops splitting after the first space and returns a single-item array, so we use "[0]" to pull out that value. The above code returns:

RESULT: '123'
TYPE: String

As long as the address numbers come first, this will consistently grab them, and won't give you odd results if a road has numbers in its name, such as 'Route 47'. The only time it wouldn't work is if you have a half address, like '4408 1/2 S Benjamin Rd'.

- Josh Carlson
Kendall County GIS

View solution in original post

2 Replies
jcarlson
Regular Contributor II

I don't know what your address data looks like, but assuming there's a space between the numbers and the street name, you could try using Split.

var addr = '1223 S Main St'

return Split(addr, ' ', 1)[0]

By including the limit argument, the function stops splitting after the first space and returns a single-item array, so we use "[0]" to pull out that value. The above code returns:

RESULT: '123'
TYPE: String

As long as the address numbers come first, this will consistently grab them, and won't give you odd results if a road has numbers in its name, such as 'Route 47'. The only time it wouldn't work is if you have a half address, like '4408 1/2 S Benjamin Rd'.

- Josh Carlson
Kendall County GIS

View solution in original post

KimberlyRieger
New Contributor II

Josh, that worked perfectly! thank you so much!