Select to view content in your preferred language

Calculate sum of time durations in Survey123 Connect

115
2
Jump to solution
Thursday
JohnathanAdkins
New Contributor

I am able to calculate the duration of time in minutes from four different UAV flights (One being required and the others optional) BUT I have not been able to calculate the sum of all of them. For all of the flight times I am pretty sure that I converted them to integers instead of strings but whenever I try to perform a sum function in my ${total_ft} field, I either get an error message or they come out looking like a string (ft1 = 3 minutes, ft2 = 4 minutes, Result = 34). 

Is this something that could be wrong with how I am setting up the bind::esri:fieldType settings? I have a date question earlier in the survey but would this potentially require me to restructure how I have the "time" question types formatted?

I am doing this in Survey123 Connect (Template Version 3.22)

 

0 Kudos
1 Solution

Accepted Solutions
LeeButler
Esri Contributor

Here's an updated version of your Survey123 form that should be calculating the total time correctly.

For the the ft fields I used the coalesce formular to return a 0 if no flight has been recorded rather than an empty value.  I did this as otherwise the final total calculation wouldn't work.

For the total_ft calculation I then added each ft field as an integer:

int(${ft_1}) + int(${ft_2}) + int(${ft_3}) + int(${ft_4})

This seems to be working for me

View solution in original post

2 Replies
LeeButler
Esri Contributor

Here's an updated version of your Survey123 form that should be calculating the total time correctly.

For the the ft fields I used the coalesce formular to return a 0 if no flight has been recorded rather than an empty value.  I did this as otherwise the final total calculation wouldn't work.

For the total_ft calculation I then added each ft field as an integer:

int(${ft_1}) + int(${ft_2}) + int(${ft_3}) + int(${ft_4})

This seems to be working for me

JohnathanAdkins
New Contributor

Hey this seems to work out well for me too!

Thank you!