Displaying select_multiple all labels using choice-name

I am working in xlsform and I want to display all the options selected in a
select multiple question in another part of the survey, but when I
use jr:choice-name(${Procedure}, '${Procedure}') where Procedure refers to
a select_multiple question and then use a note to return ${calculate_1}
where calculate_1 is the jr: code line, I can only get one choice to
appear. Any thoughts?

Thanks,

Elizabeth,

jr:choice-name() expects to be given one selection only. You'll need to
manually call selected-at() to get each choice, pass that to
jr:choice-name() (as the first parameter), and then concatenate that with
another. For example:

concat(jr:choice-name(selected-at(${Procedure}, 0), '${Procedure}'), ', ',
jr:choice-name(selected-at(${Procedure}, 0), '${Procedure}'))

That would concatenate the labels of the first two choices together, with a
", " between them. That's a bit tedious, of course, and doesn't look great
if only one option is selected. There are more advanced techniques you
could use with repeat groups: you could pull each selection into a repeat
instance, then use join() to pull them all together; but that's a more
advanced maneuver.

Best,

Chris

ยทยทยท --- Christopher Robert Dobility, Inc. (SurveyCTO) http://www.surveycto.com/ http://blog.surveycto.com/

On Sat, Jul 25, 2015 at 11:20 AM Elizabeth L. elizabeth.m.ludwig@gmail.com wrote:

I am working in xlsform and I want to display all the options selected in
a select multiple question in another part of the survey, but when I
use jr:choice-name(${Procedure}, '${Procedure}') where Procedure refers to
a select_multiple question and then use a note to return ${calculate_1}
where calculate_1 is the jr: code line, I can only get one choice to
appear. Any thoughts?

Thanks,

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

1 Like

Does the concat statement go in the calculation column in survey ? I am
getting an error message when I add it there.

If, say, I have 8 choices that I want to have the option of drawing on all
of them, would it then be
or concat(jr:choice-name(selected-at(${Procedure}, 1), '${Procedure}'), ',
', jr:choice-name(selected-at(${Procedure}, 1), '${Procedure}')) ? and
through 8? in the same calculation column

Thank you for your help

ยทยทยท On Saturday, 25 July 2015 11:30:02 UTC-4, Christopher Robert wrote: > > Elizabeth, > > jr:choice-name() expects to be given one selection only. You'll need to > manually call selected-at() to get each choice, pass that to > jr:choice-name() (as the first parameter), and then concatenate that with > another. For example: > > concat(jr:choice-name(selected-at(${Procedure}, 0), '${Procedure}'), ', ', > jr:choice-name(selected-at(${Procedure}, 0), '${Procedure}')) > > That would concatenate the labels of the first two choices together, with > a ", " between them. That's a bit tedious, of course, and doesn't look > great if only one option is selected. There are more advanced techniques > you could use with repeat groups: you could pull each selection into a > repeat instance, then use join() to pull them all together; but that's a > more advanced maneuver. > > Best, > > Chris > > --- > Christopher Robert > Dobility, Inc. (SurveyCTO) > http://www.surveycto.com/ > http://blog.surveycto.com/ > > On Sat, Jul 25, 2015 at 11:20 AM Elizabeth L. <elizabeth...@gmail.com > wrote: > >> I am working in xlsform and I want to display all the options selected in >> a select multiple question in another part of the survey, but when I >> use jr:choice-name(${Procedure}, '${Procedure}') where Procedure refers to >> a select_multiple question and then use a note to return ${calculate_1} >> where calculate_1 is the jr: code line, I can only get one choice to >> appear. Any thoughts? >> >> Thanks, >> >> -- >> -- >> Post: opend...@googlegroups.com >> Unsubscribe: opendatakit...@googlegroups.com >> Options: http://groups.google.com/group/opendatakit?hl=en >> >> --- >> You received this message because you are subscribed to the Google Groups >> "ODK Community" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to opendatakit...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> >

Elizabeth,

I think that I missed a close paren at the end of the statement, which may
explain the error. Try adding one to the end, and also try to see if all of
the open parens are closed. (And yes, I expect that you'll put this in the
"calculation" column -- though it will depend a bit on what you're trying
to do.)

Best,

Chris

ยทยทยท On Sat, Jul 25, 2015 at 1:57 PM Elizabeth L. wrote:

Does the concat statement go in the calculation column in survey ? I am
getting an error message when I add it there.

If, say, I have 8 choices that I want to have the option of drawing on all
of them, would it then be
or concat(jr:choice-name(selected-at(${Procedure}, 1), '${Procedure}'), ',
', jr:choice-name(selected-at(${Procedure}, 1), '${Procedure}')) ? and
through 8? in the same calculation column

Thank you for your help

On Saturday, 25 July 2015 11:30:02 UTC-4, Christopher Robert wrote:

Elizabeth,

jr:choice-name() expects to be given one selection only. You'll need to
manually call selected-at() to get each choice, pass that to
jr:choice-name() (as the first parameter), and then concatenate that with
another. For example:

concat(jr:choice-name(selected-at(${Procedure}, 0), '${Procedure}'), ',
', jr:choice-name(selected-at(${Procedure}, 0), '${Procedure}'))

That would concatenate the labels of the first two choices together, with
a ", " between them. That's a bit tedious, of course, and doesn't look
great if only one option is selected. There are more advanced techniques
you could use with repeat groups: you could pull each selection into a
repeat instance, then use join() to pull them all together; but that's a
more advanced maneuver.

Best,

Chris


Christopher Robert
Dobility, Inc. (SurveyCTO)
http://www.surveycto.com/
http://blog.surveycto.com/

On Sat, Jul 25, 2015 at 11:20 AM Elizabeth L. elizabeth...@gmail.com wrote:

I am working in xlsform and I want to display all the options selected in

a select multiple question in another part of the survey, but when I
use jr:choice-name(${Procedure}, '${Procedure}') where Procedure refers to
a select_multiple question and then use a note to return ${calculate_1}
where calculate_1 is the jr: code line, I can only get one choice to
appear. Any thoughts?

Thanks,

--

Post: opend...@googlegroups.com

Unsubscribe: opendatakit...@googlegroups.com

Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google
Groups "ODK Community" group.

To unsubscribe from this group and stop receiving emails from it, send an

email to opendatakit...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Chris, @crobert

Is there any chance you could elaborate on the more elegant version to this solution with regards to using repeat groups and then pulling each section into a repeat instance and then using join() to pull it all together?

Best wishes,

SY

Hi SY,

There's not much to it, really: if you had a repeated calculate field named "choicelabel", then you could just join them all together into a comma-separated list with something like:

join(', ', ${choicelabel})

See more on the join() function here.

For more on moving between a select_multiple field and a repeat group, you can also see this sample on asking follow-up questions for selected options.

Best,

Chris

3 Likes