I am trying to save the household member name or roster number of a household individual in a variable for export based on 3 questions.
1st question is linked to a roster of household members(names).
2nd question displays 2 of the previous selected members.(1st question enables this)
3rd question selects the oldest of the previous 2 members.(2nd question enables this)
So if only the 1st question is answered save the value in the variable.
If the 1st and 2nd questions are answered save the value of the 2nd question in the variable.
If all 3 questions are answered save the value of the 3rd question in the variable.
I apologize if this question has been asked already. If it has please share the link to the question.
Well, nobody has asked exactly the same question.
But abstractly speaking, if you have three questions
q3 and you want the value of the last answered the operator you need is the ternary operator ?
Something along the lines:
q2 may be pointing to
q3 was not answered (refused, for example). Then instead of the shortcut above you’d need to put the full enabling conditions for each question, rather than the
Thanks for your response.
What I’ve tried was:
IsAnswered(q3) ? q3: (IsAnswered(q2) ? (q2) : (q1))
But I got this error.
Type of conditional expression cannot be determined because there is no implicit conversion between WB.Core.SharedKernels.DataCollection.RosterVector and int
The message indicates the compiler can’t resolve the type of the resulting expression.
Probably your q1 and q2 and q3 are of different types.
Question q1 and q2 are multi select questions and q3 is a single select question
Thanks for describing, then the program is right.
Indicating single-select or multi-select is insufficient to determine the data type, since they have many variations.
Please, refer to the following table:
Thank you I was able to resolve the problem by changing variable to a string.
A string is a universal storage container that usually fits in almost anything else.
Yet bear in mind not to loose any information with that if it is essential.
For example, if you have two Sergiys in your household, storing the name “Sergiy” will loose the information, which of the two it is. (while storing the index will preserve that).
So, even though it is less readable, I’d store “1; 3” instead of “Sergiy; Maryna” or else you need to take care of the duplicates, and will still need to do a search in the data to discover other properties of the selected persons (like age or employment, for example).