# Survey123 - Calculate to 2dp

5514
8
08-30-2017 08:58 PM
Esri Contributor

Hi there

I have a sample survey where I have a complex calcualtion, however I am interested in getting all answers with  2 decimal places only

I see that we can  edit the schema length, but with the way field length works we wont always consistently get 2dp

John P

Tags (3)
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi John,

Have you considered using the 'round' function on your calculation:

round(\${test}*1.14569875,2)

This will round the answer displayed to 2 decimal places and also submit the answer to feature service as only 2 decimal places.

Regards,

Phil.

8 Replies
by Anonymous User
Not applicable

Hi John,

Have you considered using the 'round' function on your calculation:

round(\${test}*1.14569875,2)

This will round the answer displayed to 2 decimal places and also submit the answer to feature service as only 2 decimal places.

Regards,

Phil.

New Contributor III

Phil,  I see how this works for decimals but how can whole numbers be rounded? I need to round to the nearest 100.

Esri Esteemed Contributor

Hi Marc,

There are a couple of ways to round to the hundreds (and by extension, any order of magnitude):

• round(\${q}, -2) will round to the nearest hundreds (last two integer digits 0) - note this will round up if the value is greater than 50
• \${q} - (\${q} mod 100) will subtract the modulus (remainder) from dividing by 100 from the number, rounding it down to an even hundred
New Contributor II

Do these work when setting up the feature report word doc template? I am trying to round some lat/long values but don't want to go through the effort of creating a new field with a calculation in the Survey123 app.

Would a format like this work?: \${round(q,-2)}

I am wondering if this works for more than just the conditional element calcs as shown here: https://doc.arcgis.com/en/survey123/browser/analyze-results/featurereporttemplates.htm

\${if integer1>0}

by Anonymous User
Not applicable

Hi Marcus,

No, this is not supported in the feature report templates. The best way is to set up a hidden question on survey that does the rounding and final calculation, and then display that in the your feature report, not the originally entered value.

Phil.

New Contributor III

Hey Phil, is there a way to round up? For example if the result of calculation is 71.415, is there a way to get the value to be 72? I have a calculation for estimating no. of employees where I'd rather have a conservative estimate instead of nearest round number.

by Anonymous User
Not applicable

Hi @PrachiPatel,

Are you refering in the XLSForm in Connect/field app, or in the feature report template?

In either case there is no out of box supported function such as roundup that you may see supported in Excel, as the XSLForm open standard does not support it.

You could try and build your own expression to achieve what you are after, similar to what James outlined above. It will all depend on the values and types of number you need to round up to.

Regards,

Phil.

New Contributor III

Hi Phil

I am calculating in the .xls form. Thank you for your response. I went ahead and put the following calculation and it is working

if( (coalesce(\${AREA},0) div 200) > round((coalesce(\${AREA},0) div 200),0), round((coalesce(\${AREA},0) div 200),0) +1 , round((coalesce(\${AREA},0) div 200),0))