Substitutions from a roster made using multi select question

Hi
We are creating a roster using a multi-select question with three categories as other (other_1, other_2, other_3). We need the interviewer to specify the other category as text in case they select either of the above three options. Also, we want to use the specified answer as the roster title later for substitutions. What would be the best way to achieve this?

Hi,
assume at your multi-select question (variable name MSC_Q) , other_1 takes option value 990, other_2 991 etc. Your roster is named msc_roster.

You can achieve that through one of the below:

  1. Create three text questions right after your multi-select question. msc_oth1 with enabling condition MSC_Q==990 and question text “Please specify other 1”. msc_oth2 with enabling condition MSC_Q==991 and so forth.

  2. Create one text question within your roster, e.g. called msc_oth with enabling condition @rowcode.InList(990,991,992)

I tend to prefer approach 2. which I’d also use to achieve your second objective:

I’d create a new string variable within roster msc_roster called custom_rostertitle. It stores the specified “Other option” if within roster row 990…992 or the regular name of the row. You can achieve this through expression:

@rowcode.InList(990,991,992) ? 
msc_oth : 
msc_roster[@rowcode].rowname 

In subsequent questions within the roster you can simply use %custom_rostertitle% instead of %rostertitle% as a substitution.

In addition you can also use custom_rostertitle for a custom title of the roster box itself (select your roster and tick box “Custom title” -> replace %rostertitle% with %custom_rostertitle%.

1 Like

Thanks a lot. This was very helpful!

Follow Peter’s advice. Here is how the result may look like:

Perhaps it is also desirable to add a check that the ‘other 3’ is only selected when both ‘other 1’ and ‘other 2’ are selected, so that there are no gaps in selection of others.

Here is the condition you may use

!self.ContainsAny(991,992,993)
||
(self.Contains(991) && !self.ContainsAny(992,993))
||
(self.ContainsAll(991,992) && !self.ContainsAny(993))
||
self.ContainsAll(991,992,993)

(I started numbering with 991, so that 991 denotes ‘other 1’ for readability)

In addition to two options listed by Peter, sometimes you may get away with asking the name of the other item already in the details roster. But this is rare (such as if you expect the answer to the question “Which tablets do you use?” being “I use Samsung, LG and two other tablets”, but mostly people will say “I use Samsung and Nexus” necessitating the immediate entry of the other item somewhere").

1 Like

We were missing out on making sure that there are no gaps in terms of selection of the options. Thank you Sergiy. This was further useful.

After re-reading @peter_brueck’s expression in the post above, I’ve noticed that he has cut a corner a bit, by using the @rowname system variable (rowname maps to @rowname, technically).

In light of the discussion here:


such solution may stop working in the future.

Instead @priyankaecondse could use customization of the roster titles, as introduced in Survey Solutions v20.04.

See the section “Tablets” in the Public example User questions and common patterns

1 Like

Thanks Sergiy,

I was actually surprised that .rowname still worked.

The public example “Tablets” nicely circumvents the use of rowname for the roster titles itself.

However, with the system variable @rowname (or .rowname) being discontinued at some point, there is no way to get a variable that takes either the “Row Name/%rostertitle%” or the “Other, specify” to be used in substitution, correct?

A variable (defined as a C# syntax expression) shall have no access to the %rostertitle% or other visible text or else it creates a vulnerability for programming mistakes which are almost impossible to detect.

The reverse is not true. A %substitution% may refer to a variable without any difficulty: %age%, %city%.

Correspondingly, if you need to show (perhaps as part of the question) the clarification of other, that must be a second substitution:

How long do you live in %rostertitle% %otherspec%?

where otherspec is to be defined as value of other or blank (same as it is done in the customized roster title in the example).

1 Like

Thanks for the clarification!

Thank you. This is of great help!