Repeat loop for a multiple select questions

I want to add a dynamic repeat loop for a multi select question. The user chooses multiple options from the list, and has to answer further questions for each selected option.
For example, if I choose A,B,C,D,E from the multiple select list, I should be further answering set of questions for each option.
Is it possible do achieve this? If so, how do I do that?
Any help is appreciated. Thanks in advance.

Yes, it is possible.

Dear Paani

Please check out this link !

paani.xls (9.5 KB)


I have this same problem that I’m trying to solve, but when I add a column in the XLS form with a heading of repeat_count, I get an error when trying to load: * SyntaxError: The string did not match the expected pattern.

I thought I was doing something wrong, but I have now tried this with several samples that I’ve downloaded and in every case I get the same error. Uploading my XLS file to help with possibly identifying my problem. Attendance M&E5.xls (25.5 KB)

Thanks in advance for any help!


Myard for your syntax problem is it sure it is due to the column repeat_count? I saw names with majuscule letters.
A question text has a calculation formula, how does that work? i though formulas of calculation are used only if the type is a calculate no?
Paani, you want to add additional questions according to multiple choices answer, i would suggest to write the formula selected(${question},‘answer1’) in the column Relevant for the question you wanna ask if it has been answered answer1 in the question question.

Then you ask different question regarding the answer that were responded
However i don’t get in your question why you want it to be looped if so you can still use the same relevant formulas…

Hope i answered and understood well….


Hi Quentin,

Thanks for your response. I have done some experimenting and discovered the error goes away if I load the same XLS Form in Chrome instead of using Safari. So my example above works fine. Paani, if you check the example Attendance M&E5 that is linked above, you should see how to solve your original problem.

Quentin, the calculation formula in the text field is to provide a default response based on previous questions. I have not been able to put a calculation or a reference to a previous response in the default column, but it works if I put it in the calculation column. The downside is that if a user overrides the default, then later changes one of the responses used in the calculation, the calculation takes precedence over the user-provided response. e.g. if I have Start Date and End Date, and use these to calculate Number of Days, the user may want to override my calculation if the event had a break for the weekend. But if the user later discovers an error in one of the dates and changes it, the Number of Days will be recalculated, overwriting the user’s response. I can live with that for now, but later I may try to use and if condition to ensure the user’s response has priority.


I may have spoken too soon. This form works very well in Chrome and Firefox on my Mac. It does not work in KoBoCollect on my Android device, nor in Safari on my Mac; or in Safari, Chrome or Firefox on iPad. Any help in resolving this much appreciated.


Hi myard,

Tank you for your explications about it. I have to say that your form is a bit unorthodox ahah and that it oculd be the cause of your problems.
According to me, it’s not possible to writte capital letters in the names column to start with, then this use of calculation in a text type is really awkward for me… i would use calculate with a relevant condition and a text note after if i want to writte something related to this calculate…

Try to clean the majuscules and clean these things…

A good way to know where the mistake is is also to load part per part the survey, start with the first question and add the following line in your form, load it and if it works it means the mistake in after in the form…
Seems long but it’s actually quicker to find a mistake! Good luck!

I am sorry, but as far as we experienced:

  • Variable reference can be used in labels (and msgtexts) like $[var}, and the two examples in the Attendance xls from myard
  • but NOT expressions in labels, like if(…) conditions, other functions …
  • It is also possible to use a text (e.g. also read-only) or note type as output with a calculation, which creates the text/value shown (not the label!). In rare cases you may need to cast the type, like (string(…), and it may pose a problem if the calculation returns a node type.
  • You are free to use capital and mixed letters for names, just they need to be unique in the name space. (Even, “choices” (sheet) list name can be the same as “survey” (sheet) name.)
    Kind regards
1 Like

Correction: it is certainly possible to use variable references in if() statements (or any other function), either as part of the condition expression, or as part of the true/false results. Try this simple form:

iftest.xls (5.5 KB)

Oh, I am sorry, EN was to misunderstand. I wanted to say IF(…) not working in labels. I re-edited above. Thanks for helping to get it clear.
Kind regards

Ah. Gotcha! :slight_smile: Correct, you can only reference XML instance elements (aka ‘variables’) in labels and hints. If you want to display an expression (in a label of hint) then you’d have to first add a calculation for it - so that the value ends up in the XML instance, and then reference that accordingly.

BTW, although technically you can in XLSForm (though not via Kobo) have a calculation in a regular number or string question, so that the calculated value appears as the value of the question, I’d recommend against is as the user may be lead to believe they can overwrite this apparent ‘default’ (calculated) value. But in reality anything they type in will eventually get re-clobbered by the calculation (though they may not happen to see it…)

1 Like

Can make sense sometimes, like

  • for a read-only variable, for example to show a result to the user.
  • for a dynamic “default” calculation with once(…), which would allow editing.

Hi @wroos
I always use calculation with text, integer, date, or even select_one questions when I don’t intend the response to be changed but visible. So you are right when you say the application of read_only would help in the situation.