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

6294
15
Jump to solution
02-23-2018 03:03 PM
Syvertson
Occasional Contributor III

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.

Tags (1)
0 Kudos
15 Replies
XanderBakker
Esri Esteemed Contributor

I'm sorry to hear that you run into problems using the attribute rules. This is the first version in which attribute rules are available and as you pointed out it is currently not capable of replacing all the functionality the attribute assistent is offering for ArcMap. However, in coming versions more and more functionality will be included and it will eventually go further than what the attribute assistent if capable of doing. I would advice you to log the problems you encounter with Esri support, to make sure those get resolved. 

0 Kudos
Syvertson
Occasional Contributor III

OK.  Thanks again Xander.  And that makes the point I am making, that Key functionality is missing.  

When every workflow I attempt to replicate in Pro ends up in disappointment over "not quite ready" technology, it is frustrating -- Especially when all I hear is that it is time we should be migrating that way.  I wouldn't be frustrated if I just ignored and stayed on ArcMap, but I am usually an early adopter of technology.  I keep making these attempts and investing time into a project and then find out I need to just go back for now.  I really do want this to work out, because the things that do work are really cool.

MarcoBoeringa
MVP Regular Contributor

Are you sure the:

Timestamp()

function returns the appropriate data type for the field you are trying to calculate? I can imagine a situation where the actual syntax of the expression is valid, but the returned data type not, and maybe causing issues when adding or truly executing the attribute rule. E.g. if your field to calculate is of type text instead of date, it might cause an issue. Timestamp() returns a true date (Date Functions | ArcGIS for Developers )

This is just a wild guess though, I don't have experience with the new attribute rules functionality.

0 Kudos
XanderBakker
Esri Esteemed Contributor

There is a related thread here: Can an arcade attribute rule update a date field?  My guess is that some functionality related to dates and attribute rules may need some adjustments.

0 Kudos
Syvertson
Occasional Contributor III

Thanks Marco.  I did attempt "Text(Timestamp())" as well.  Here is the attribute information:

0 Kudos
KoryKramer
Esri Community Moderator

Matthew, I apologize that you're experiencing issues in starting to work with attribute rules.  It looks like this specific issue that you've noted has been logged in our technical support system as BUG-000112098 - ERROR 000358: Invalid expression when applying an Arcade date function to a date field thru Attribute Rules

If you are interested in being attached to the bug, please open a case with support and request to be attached. 

Thank you.