Select to view content in your preferred language

Unable to use decimals in calculation

592
3
Jump to solution
10-16-2023 02:04 AM
ChampionAmaury
New Contributor II

Hello 😀 !

I am facing a problem with decimals, in my Survey123 project, the operator must enter a decimal number in a field. Later in the formular, the entered value is used in a calculation, but it doesn't work ! I tried to diplay the value in another field to see if there's a problem with it. It seems like when the value is an integer (e. g. "8"), there's no problem, but when a decimal value is entered (e. g. "3.2"), nothing happen, like if the value was not considered at all. 

I recreate my problem in the following formular : 

ChampionAmaury_0-1697446784676.png

When the entered number is an integer, here "10", I am able to display the value and use it in a calculation :

ChampionAmaury_1-1697446820434.png

When the entered number is a decimal, here "2.3", nothing happen : 

ChampionAmaury_2-1697446928702.png

I would be extremly happy if one of you could help me ! 

my version of Survey123 is 3.9.120

Amaury

 

 

 

Tags (2)
0 Kudos
2 Solutions

Accepted Solutions
ChampionAmaury
New Contributor II

Thank you for your answer ! I found a solution through your idea. I replaced the "type" from "decimal" to "text" then I can use the command number(...) to use the value as a number

View solution in original post

0 Kudos
DougBrowning
MVP Esteemed Contributor

Be aware doing it this way means the field will be stored as text which may be a pain later when using the data.

Inside the form 123 defaults to text esp on notes.  You can set the bind::type field to decimal and then it will work as you wanted.  If you want the database note to be decimal also you can also set the bind::esri:fieldType column.

Hope that helps

View solution in original post

3 Replies
MobiusSnake
MVP

I've wrestled with a similar issue where the focus doesn't seem to leave a decimal question (triggering the calculation) until something else forces it.  If you add a text question below your notes and click on it after you fill out the decimal question, does the calculation take place?

Strangely not all types of questions seem to make decimals lose focus, radio buttons don't work but checkboxes do, for example.

0 Kudos
ChampionAmaury
New Contributor II

Thank you for your answer ! I found a solution through your idea. I replaced the "type" from "decimal" to "text" then I can use the command number(...) to use the value as a number

0 Kudos
DougBrowning
MVP Esteemed Contributor

Be aware doing it this way means the field will be stored as text which may be a pain later when using the data.

Inside the form 123 defaults to text esp on notes.  You can set the bind::type field to decimal and then it will work as you wanted.  If you want the database note to be decimal also you can also set the bind::esri:fieldType column.

Hope that helps