When filling out a Survery123 form using a browser, my calculations from Survey123 Connect do not go through. On my mobile device and the desktop app they work. Is this know issue? Is there something I can do to get this to work on the browser?
I don't think I understand coalasce. Doesn't it return the first non-empty value of two fields? I have eight fields, and want the running average of the ones that have been answered, as not all eight questions will be answered all the time. Both Survey123 Connect and Survey123 Mobile give me the running total, however the webform does not.
Hi James,
Coalesce returns the first non-empty value of the two inputs - an input can either be a question or a value. You can use it within your summing formula. I would not expect the calculations to run on the field app and connect; that would technically be a bug based on how calculations have been defined.
Please don't fix that bug!
at least, not until functions exists that allow a running total. Looks like coalasce() wouldn't help as I have more than two inputs and never know how many would be populated (I had hopes for sum() and count() but they only work for repeats). In the mean time, I will push users to the mobile app.
Hi James,
To address the multiple values - coalesce(), like if(), can be nested to accommodate multiple conditions. In your form, it looked like you could have implemented it in the calculate questions to accomplish without nesting.
HiJames Tedrick, I too am having issues with the calculations on the webform not calculating answers from previous questions, whereas the same survey using the Survey123 app on my mobile device/computer does work as expected. It would be nice to understand the requirements, my error, or if there is an issue?
As noted the Survey123 apps show the calculation (in my case the difference between two time fields, when a lift is reopened). The fields on the web form do not update as expected. For client reasons, I want to be able to rely on web version rather than the app so this is a bit of an issue.
I have tried to use the number() function and did not change to the output. For example,
int(number(${StartTime}) - number(${StopTime})) div (1000*60)
It is as if the webform is not dynamic?
Thoughts, appreciated.
Web form:
Hi Ryan,
In the web form, time is treated as a text object. This will be addressed in the next version of Survey123 by introducing the decimal-time() function to convert time to a fractional day (i.e., 6:00 am = 0.25). From there mathematical operations can be done.
Thank James, so specific to time calculation these are not supported in the web form ?
Based on your comments I can see what you mean now if I add a note field (graphic below).
Looking at samples and doc... it states this should be accomplished with decimal-date-time()? However it does not work in the web when tested. . So this statement is not true?
Decimal date time—Survey123 for ArcGIS | ArcGIS
https://community.esri.com/groups/survey123/blog/2016/04/17/dates-and-time-in-survey123-for-arcgis
Objective | Epoch time calculation | Decimal time calculation |
---|---|---|
Time spent for lunch in minutes | int(${LunchEnd} - ${LunchStart}) div (1000*60) | int((decimal-date-time(${lunchends}) - decimal-date-time(${lunchstarts})) * 24*60) |
Hi Ryan,
In the web form in particular, there is a distinct difference between a datetime object and a time object; the decimal-time() function is needed to translate the time value (which is stored as a string) to a numeric value suitable for calculations.
Hi James,
Can we please confirm if it's possible to use calculations like format-date in the Web Form?
Looking at using format-date(${sample_date}, '%W') to calculate an integer question, where sample_date is calculated to today(). Works fine in the app, but has an issue in the web browser due to above thread.
I've been looking to try and workaround the issue with conversions without success.
Thanks,
Chris
Hi Chris,
The %W (week number) is only available in the field app; it's not part of the standard XLSForm specification for format-date.