How to format display of calculated result in Survey123

4530
13
Jump to solution
12-06-2017 09:46 AM
JimTolbert
New Contributor III

I am using Survey123 for a Road Tour app.  Part of that is calculating the square yards of a segment.  Currently, I am successfully calculating the area with a "calculate" statement as displaying the result with a "note" statement.  I have been unable to successfully format the result to an integer.  I have tried input mask, but it is not an input and I tried "esriFieldTypeInteger" in the "bind::ersi:fieldType".   The length and width are read from previous data with pulldata().  Any suggestions?  Many thanx............ jt

0 Kudos
1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Jim,

You will need to manually apply the conversion to integer in the calculation.  There are two functions that you could use:

- int() - transforms to integer by dropping the non-integer portion

- round() - rounds the result; using 0 as the number of decimal places will result in an integer

View solution in original post

13 Replies
JimTolbert
New Contributor III

Screen shot of Survey123 Connect

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Jim,

You will need to manually apply the conversion to integer in the calculation.  There are two functions that you could use:

- int() - transforms to integer by dropping the non-integer portion

- round() - rounds the result; using 0 as the number of decimal places will result in an integer

JimTolbert
New Contributor III

Perfect!  Thanx!   

Now I want to take that result and multiply by a factor ( number of ways to do that) so that, in the screen shot above, it would show

Asphalt Overlay ~ $117,320  (which is $40 per sqr yard * total Square yards)

Chip Seal ~  $9,326 ( which is $3.18 per squ yard * total square yards)

etc.

Any suggestions there?

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Jim,

That shouldn't be an issue - if the number is hard-coded, you can include it in the calculation or as an additional calculation.  It could also be a choice list or other question and then plugged into the formula by reference.

0 Kudos
JimTolbert
New Contributor III

Hi James.... My query is more on utilization of real estate on the screen.  What I have now is a select multiple other statement.  Can I put a calculation into the options for the selection list? I have tried just adding ${var-name} in the label and that didn't work.   Thanks much for your help! 

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Jim, 

Could you either share your form or display/describe the questions in more detail?  I'm not sure how a select-multiple statement could be used in price calculations- you would normally need 1 price in the calculations.

0 Kudos
JimTolbert
New Contributor III

Hi James.....

So after calculating the area, I want to list what some of the treatment options would cost as a discussion topic for those on the Road Tour.  What is below works, but it doesn't look very good and uses alot of screen real estate.    Idealy, the approximate costs could be part of the choices where the treatment is selected.  Since I can't figure that out, I posted the costs as a group ( that could be shown or not) but there I can't format it so the calculated value was after the label.... eg.  2" Asphalt Overlay ~ $117k  or 2"Asphalt Overlay ~ $117,320

Is that a little more clear?  I can post the whole spreadsheet, but pointing out where I am working could be a bit of challenge.   What do you suggest?

I really appreciate all you help.................. jt

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Jim,

Thanks for the example - this definitely helps.  A couple of ideas:

  • You have the ~$ part of the figure in the label part of the note.  You could place it in the calculation to join it to the number: concat("~$", round(${AREA}*40,0))
  • You certainly could also divide by 1000 in your calculation to get the "K" value and add that into the concat() statement.  Depending on how complicated you want to be, you can also try to put some logic in for when K or the normal value is needed

Survey123 currently doesn't have support for dynamic label values - I'll log this as a possible enhancement

0 Kudos
JimTolbert
New Contributor III

Hey James.... Thanks much...  concat will put the dollar sign in front of the value.     It will still display on two lines though, won't it?  And there isn't a format mask that can be applied anywhere to add the comma after three digits.... (eg $2,345,678 vs $2345678)

Thanks again............ jt

0 Kudos