survey 123 decimal places

9148
10
08-29-2017 01:09 PM
JB
by
New Contributor III

I am new to using survey 123 so I apologize for the question. I want to set it so only one decimal place can be entered when the field teams fill in the form. Is there a formula so I can do this.

thank you in advance

Tags (2)
10 Replies
IsmaelChivite
Esri Notable Contributor

Hi!  I suggest you try the inputMask column in your XLSForm.  You can find info about inputMaks in this help topic. It looks like a value of 9.9 in your inputmask would do the trick.

The input  mask controls user input as values are entered in the input box.  Incorrect values are shown in red, but  once you have a value that  matches the mask it will switch to black.

Another approach is to use a regular expression in the constraint column.

By the way! Once you can spell Survey123 without a space between Survey and 123, you qualify as a Survey123 Ninja. 

TL2
by
Occasional Contributor III

What about specifying the scale on a decimal for calculated values.  inputMask seems to only work when you know the precision and scale, like a percent (99.9%).  I need to show 1 place past decimal even if it is 0; .1, 1.0 or 200.0 needs to be allowed.  The round function knocks off the 0, but I need to show scale of 1 no matter.

0 Kudos
BlytheSpendlove2
New Contributor III

I have this question too. I want to restrict the users to one decimal place but let the user input something like 30.3 or 3.1 without having to write 03.1, because the survey users won't know what the precision and scale is. Has anyone ever found a work around to this?

https://community.esri.com/migrated-users/3966  What do you mean above by putting a regular expression in the constraint column? Would we have to put in all the possibilities such as 0.1, 0.2, 0.3............99.9 etc?

0 Kudos
StephenM
Occasional Contributor II

You could restrict users to one decimal place using a regular expression in the constraint column.

This regular expression, for example, allows the user to input between 1 and 10 numbers before the decimal, and 1 after:

regex(., '^[0-9]{1,10}\.[0-9]{1}$')

This page has some details and examples dealing with regular expressions:

Formulas—Survey123 for ArcGIS | ArcGIS

BlytheSpendlove2
New Contributor III

That is a great idea, thank you!

0 Kudos
PaulTremblay
New Contributor II

Hello.  I tried entering the regular expression above in the Constraint field and it doesn't seem to work.  The Type field is set to decimal.  I'm trying to have the users enter a value from 0 to 99 and include 1 decimal place only.  I've also entered 99.9 in the Input Mask field, but that forces the users to enter a leading 0 for values less then 10.  Any help would be appreciated.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Paul,

I tested the regex above and it is working properly- the constraint appears when I press the 'validate' button in Connect.

0 Kudos
PaulTremblay
New Contributor II

James, I figured out that in order for the constraint to work, you need to press the 'validate'...rookie move on my part.  Thanks for the confirmation.

0 Kudos
BradWeir
New Contributor II

Tried this constraint, it works but it will not let you enter a decimal value of '0'. The following expression worked for me: regex(., '^\d{0,2}(?:\.\d)?$'). In this way the decimal is optional, so you can just leave it as a whole integer if you want.

0 Kudos