Validating linked multi-select question based on array formed from roster response

I have a multi-select question that asks: “who in your household was employed in the last 12 months?”, that is linked to a household roster.

Earlier in the questionnaire, I have a section on vocational training where for each member from the household that received vocational training we ask “Did this person find work or is currently employed as a result of the training?” in a roster formed by a list question filtered for training recipients.

I would like to have a validating condition on the question “who in your household was employed in the last 12 months?” that checks that the members who found a new job are selected, i.e. l1_0a_employee_hh.Contains(array from vocational training roster). However, I cannot figure out how to build the variable storing the array of row indices from the vocational training roster. I have tried the following syntax to create the array variable:
a0_hh_members.Where(b => vocational_training_roster.Where(x=>x.n6_3_new_job_train==1).Select(z=>z.@rowindex).ToArray().Contains(b.Item1))
But, it returns a variable conversion error. Maybe this is not the right solution?

Any help would be much appreciated.


Hi Grayson,

  1. Simplify l1_0a_employee_hh and link it to the corresponding roster.
    A. This will help you to simplify the filter condition at l1_0a_employee_hh to a3_age>=15.
    B. Update the enabling at roster member_wage to l1_0a_employee_hh.Any(p=>p[0]==@rowcode)
    C. Not absolute necessary I think, but a good convention to follow whenever possible (at least imho)

Re the issue at hand:

  1. Basically you want to compare two arrays with C#
    A. First Array ‘A’ is from [N6] and you can create it via vocational_training_roster.Where(a=>a.n6_3_new_job_train==1).Select(b=>b.@rowindex+1).ToArray() (The +1 is needed to make it comparable to your 2nd array)
    B. Your second array ‘B’ is simply l1_0a_employee_hh. However it is a jagged array (as you reference a MSC linked to a roster question, see data types).
    C. To compare these two types of arrays you can use B.All(b => A.Any(a => a.Contains(b))) which will give you the final validation condition:
All(b => l1_0a_employee_hh.Any(a => a.Contains(b)))

But please consider:

  1. The validation condition gets triggered once users start to answer l1_0a_employee_hh. This might confuse interviewers as they intend to select the “remaining” individuals . If you actually need this validation, it might be useful to move this into a subsequent static text. Or flag only as warning.
  2. It’s quite complex to reference a question from X sections before. Consider restructuring the modules and/or train interviewers sufficiently.

Best Peter

Thanks Peter! This solution works well for the validation!

I see what you mean on the potential for confusion based on the selection order. Now that you point it out, it probably would just make more sense to ask about the training and employment all at once :slight_smile: .

1 Like