Hi,
I am experiencing problems with calculations and have tried several possible solutions that do not seem to work.
One of my survey modules creates a time logbook and thus asks about how respondents spent their past 24 hours.
I start the module group by asking what time respondents woke up and what time they went to bed - time question type. I use these replies to calculate the duration they are awake:
- calculate wake_hour: format-date(${wake},‘%H’)
- calculate wake_minute: format-date(${wake},‘%M’)
- calculate wake_numeric: concat(${wake_hour},${wake_minute})
- Same for bed time and then I calculate awake_duration by bed_numeric - wake_numeric. (I use this later as a constraint)
Then, I start a repeat group (so within the module group) called activities, where I first calculate the previous end time using this formula: if(position(…)>1, indexed-repeat(${end_time_numeric},${activities},position(…)-1),…/wake_numeric), so that it would take the end time from the previous repeat or the wake time if it is the first activity log. I then reconvert this time into a HH:MM format using the calculation: concat(substr(${prev_end_time_numeric}, 0, 2), ‘:’, substr(${prev_end_time_numeric}, 2, 2)) to be able to use this as a constraint when asking about the new repeat’s end time (which has to be bigger than the previous one)(time type question).
I ask several other questions and do more calculations, but I am hoping that if I can figure out what goes wrong here, the rest will follow. I also use xpaths to refer to a previous answer in the next question, or calculate the answers label and refer to that in the following question. However, neither of these seem to work. I have tried some problem-solving options such as breaking up the module group and using multiple pages, but nothing seems to work, whilst it seems I am doing the calculations as mentioned in the Kobo guides. Following a Youtube video, I tried a simple calculation (asking number of boys and girls and then calculating today and displaying this in a note), but even that does not seem to work, which makes me think it may be a setting.
Would anyone happen to know whether I have a wrong setting that I should fix or what could be wrong with the calculations I do, resulting in them not working?
Many thanks in advance.
Best wishes,
Gin