The Arcade Count() is giving an odd error

658
4
Jump to solution
04-22-2022 09:02 AM
Labels (1)
RyanBohan
Occasional Contributor III

I am trying to use Count() for a simple count of a string in a text field in a feature table in Pro.

It should be as simple as Count(fieldname)

Error

RyanBohan_0-1650643131800.png

Works on another field

RyanBohan_1-1650643222490.png

Both are text fields

 

Tags (3)
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Oh, right! It uses that first row to validate the script. Okay, try an expression like this:

var addr = $feature['Address_From2']

Iif(IsEmpty(addr), 0, Count(addr))

 By checking if the value is null first, and explicitly giving nulls an output value, this should pass validation.

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
4 Replies
jcarlson
MVP Esteemed Contributor

Hmmm. Does it behave any differently if you use bracket notation? As in, $feature['Address_From2']?

- Josh Carlson
Kendall County GIS
RyanBohan
Occasional Contributor III

Thanks for the suggestion, I am still getting the error. 

It appears if the first row is <null> that is when the error happens.  I am using ArcPro 2.9.2

I am pulling in a csv, and exporting the table to gdb

Current work around is adding in a dummy row of values.

0 Kudos
jcarlson
MVP Esteemed Contributor

Oh, right! It uses that first row to validate the script. Okay, try an expression like this:

var addr = $feature['Address_From2']

Iif(IsEmpty(addr), 0, Count(addr))

 By checking if the value is null first, and explicitly giving nulls an output value, this should pass validation.

- Josh Carlson
Kendall County GIS
0 Kudos
RyanBohan
Occasional Contributor III

Thank you @jcarlson!  That does it.