string-length expression on decimal value returns 0

911
6
04-05-2022 08:14 AM
Anne-MarieDubois
New Contributor III

Hello,

I'm trying to use an expression to evaluate if a decimal field is empty or not in Survey123. I have found this option :

(string-length(${latitude}))>0

Unfortunately, this returns the "string-length(${latitude})" portion of this expression returns a value of 0 whenever I try to enter a decimal value.

Example: decimal not working

AnneMarieDubois_0-1649171520428.png

example: integer works

AnneMarieDubois_1-1649171577137.png

I have tried these altenatives without sucess:

  • (string-length(number(${latitude})))>0
  • (string-length(number(${latitude})))>0.0
  • ${latitude} != 'NaN'

Can anyone help me finding a way to identify empty decimal fields ?

Kind regards,

Anne-Marie

0 Kudos
6 Replies
DougBrowning
MVP Esteemed Contributor

Checking on numbers can get tricky.  Have you tried ${latitude} != '' yet?  Any empty field is usually empty string, even numbers.

0 Kudos
Anne-MarieDubois
New Contributor III

Yes I tried that already and it does not work.

0 Kudos
DougBrowning
MVP Esteemed Contributor

What about = 0 or != 0 that sometimes works for me.

0 Kudos
Anne-MarieDubois
New Contributor III

That doesn't work either. The thing is is that the available expressions don't seem to make a diffrence between an empty field OR a decimal field.

AnneMarieDubois_0-1649174463720.png

 

AnneMarieDubois_1-1649174491816.pngAnneMarieDubois_2-1649174528156.png

 

0 Kudos
DeonLengton
Esri Contributor

Hi

Try first converting it to a string and then checking it's length:

string-length(string(${latitude}))=0

Anne-MarieDubois
New Contributor III

Still same issue. It only works for integers.

0 Kudos