Require decimal

149
2
02-11-2019 09:41 AM
Highlighted
New Contributor

I'm trying to create a decimal data type in Survey123 to match my data entry QA/QC requirements and I'm running into a problem.

Here's my example:  Enter Water temperature which can range from -1.0 to 35.0 and we require temperature is recorded to a tenth of a degree. 

So we want to constrain to this range and require one decimal place (tenths).

I tried this code in the constraint field:

.>-1.1 and .<35.0 and regex(., '^-?[0-9]{1,2}\.[0-9]{1}$')

If the final value in the tenths place is 0 (e.g., 24.0) I get a constraint error, it will accept any value 1-9.

If I don't require a digit in the tenths place (....\.[0-9]{1}...) it will allow the zero in the tenths place

I tried using an inputMask but I don't like that I would have to require 4 digits to allow for the full range (e.g., 26.4) which would require entering a leading 0 for temps in the single digits (e.g., 05.4).

 

I'm new to this so any insights would be appreciated!

thanks

 

James I tagged you since you provided an answer for someone else that is super close to getting at this for me!

Tags (2)
Reply
0 Kudos
2 Replies
Highlighted
Esri Esteemed Contributor

Hi Nathan,

Unfortunately, I think you're coming into conflict with the fact that the constraint will be evaluated as a number - '24.0' will be stored as '24' as they are numerically equivalent, leading to the string check to not work

Aside from the input mask, another idea would be to set the appearance to spinner and have the default value be '0.0'- this will cause the spinner to increment in tenths.

Highlighted
New Contributor

Thanks James,

We thought that might be the problem. 

I still don't understand why excel stores a number with a 0 in the last decimal place like that (24 vs 24.0) and doesn't allow you to capture the 0 as a significant digit....anyway rant over.

Thanks again, I like the spinner idea as we have a limited range of values and will also keep the data entry folks thinking about the appropriate significant digits.

nate

Reply
0 Kudos