Calculations not working in repeat group

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:

  1. calculate wake_hour: format-date(${wake},‘%H’)
  2. calculate wake_minute: format-date(${wake},‘%M’)
  3. calculate wake_numeric: concat(${wake_hour},${wake_minute})
  4. 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

Welcome to the community, @gindupont! Maybe the community could help you out if you could put your issues one at a time instead of listing everything out. Maybe have one topic for one issue.

Hi @Kal_Lam, many thanks for your reply. I’m not sure how to break it down as all these calculations follow each other and therefore the issue may be with either one of them. I don’t seem to be able to edit the previous post, but let me try to summarise it a little here.

I ask respondents how they spent their time in the last 24h. I ask about their wake up and bed time first, before starting a repeat group asking about each activity they did. I would like to constrain the end time of activity +1 to be later than the end time of activity or in the first case than their wake up time. I use several calculations before and in the repeat group, but they don’t work. The fact that I also cannot seem to refer to an answer in a next question etc. made me wonder if it’s possible that I have a wrong setting? If not, would anyone know what else could be the issue in my calculations?

Many thanks in advance!