AnsweredAssumed Answered

How do I check an Arcade variable to see if it is numeric?

Question asked by syvertson on Feb 23, 2018
Latest reply on Mar 5, 2018 by KKramer-esristaff

I am working on a complex label in ArcGIS Pro, and trying to learn arcade in the process.  The process breaks aparttwo address fields and extracts the first part so I can use this as the "House Number."   Then I make a label using the two "house numbers."  In some cases, they put something other than a standard address in the field, so after parsing, a few would give me a word instead of a number. In other programing languages the "IsNumeric" (or similar) function will give me a boolean result so then I can test it.  How do I do that in Arcade?  I want all non-numeric to be converted to an empty string.  

 

I will post the code here, but please be kind because I am no professional coder by any stretch of the imagination, especially not in Arcade.

var x = $feature['RC_GIS.dbo.ALL_PARCEL_DATA.Street_Address'];
var y = $feature['RC_GIS.dbo.ALL_PARCEL_DATA.paddress2'];
var x1 = split(x,' ')[0];
var y1 = split(y,' ')[0];
var label;


if(x1 == '0')
{x1 = '';}

if(y1 == '0')
{y1 == '';}

if (x1 == y1)
{
label = x1;
}
else
{
if (x1 == '')
{
label = y1;
}
else
{
if (y1 == '')
{
label = x1;
}
else
{
label = concatenate([x1,y1],"-");
}
}
}

return label;

Thanks in advance for any advise you might have.

Outcomes