Pulldata with select_multiple in ODK collect

Hi !

I'd like a calculate function to automatically assign a corresponding value to values previously selected (select_multiple). I found the option of pulldata. But I'd like to do it without external csv file. So I tried
instance('drug')/root/item[name=${product}]/grouping
where
"drug" is on choice sheet the list name for the variable product
"product" is on the survey sheet the variable that triggers the calculation
"grouping" is on the choice sheet the column where the value to assign are listed for every value of drug
The XLS form uploaded successfully.

The problem is that when I download the table from the data entered, the field of that calculate is blank

Welcome to the forum! Thanks for adding your profile picture, it helps build community. We're glad you're here. When you get a chance, please introduce yourself on this forum thread.

Are you able to attach and share the XLSForm for the questions you're working on?

EVENT-COUNTRY.xls (102 KB)

Thanks for the request to introduce myself. I tried but scrolling down to the bottom (as indicated) became burdensome, that's where I shifted to another activity. Is there another option please.

I have reviewed your xlsform and noted the following to cause the error/blank values.

  1. Things to note, intance('adr') -'adr' doesn't appear in the list_name of the choices sheet. Trying using 'sign' instead of 'adr'.
  2. Reference to a select multiple question returns a space separated array, therefore, this is not unique within the choice list to enable you retrieve a specific epidno. Only one epidno can only be retrieved at a time. As a workaround you can use selected-at(${eventdicpt},x) -where x is the position of the record you want to retrieve its epidno -zero indexed. If you need to pull all the epidno for all the selected ${eventdicpt} then you can create a repeat group with the number of repetitions corresponding to the number of choices selected in ${eventdicpt}. Then iteratively pull their epidno. Have not tested this. Test and share so we can all learn.
2 Likes

@Idygee
help me understand this please