The following steps will introduce you to the ‘Filter Answer by Answers’ method which is built within our function libraries.
Using this function, you can filter a questions answers according to an-other question’s answers, making the questions answers adjust according to your needs.
For example, let’s say we have the following ‘Multi-Selection’ questions with the same scale of answers:
1. ‘Which of the following brands are familiar to you?’
2. ‘Which of the following brands did you purchase in the past year?’
3. ‘Which of the following brands did you purchase in the last month?’
We will need that answers which were not chosen in question 1 will not appear in question 2.
Answers which were not chosen in question 1 and question 2 will not appear in question 3.
Filtering Answers By Answers:
Let’s create a few multi-selection questions:
Just for this example, we can use the same answer scale in all of them:
Now we can choose the answers and configure them to be the only ones that will show on the next question:
By adding the following start script to the question we want to filter its answers:
The function will filter question 39′s answers by the answers that were chosen in question 38:
If we want to do the opposite – show answers that were NOT chosen, we can add the following start script to the question we want to filter its answers:
FilterAnswersByAnswers(39, false, QRef(38));
*Notice: Changing the value from false to true is the same like the default function we saw previously.
For example, the answers that are chosen in question 38:
Will be hidden in question 39:
There’re cases where you’ll need to perform several separate filtering commands in one question. For example: Q1, Q2 and Q3 all have the same answers list. This is a brands list of 9 brands, and the 10th answer is “None”. The filtering logic for Q3 is as follows:
- Display only the brands that were chosen in Q1
- From those displayed brands – hide those that were chosen in Q2
You cannot perform all of the above in one function call, you’ll need to do it in stages, in Q3 start script:
- First, display all answers coded in Q1 this way:
- Now we want to hide the answers that were chosen in Q2. In most cases we would use this overload function this way:
FilterAnswersByAnswers(CurrQues, false, QRef(2));
But, this would “cancel/reset” the first filtering call, because this function says: “hide only the answers that were chosen in Q2 and show all the rest”. Meaning, an answer that was hidden after the first filtering call (because it was not chosen in Q1), will now be shown after the second filtering call and that’s not what we want (we want to hide the answers chosen in Q2 within the displayed answers that were chosen in Q1).
To overcome this, use the third overload for this filtering method:
FilterAnswersByAnswers(CurrQues, false, false, QRef(2));
The extra “false” parameter (the third parameter sent to this function) is the “Reset” parameter. “False” means not to reset previous answers filtering, if made. So in this case, an answer that was hidden after the first filtering call (because it was not chosen in Q1) will stay hidden after the second filtering call as we wish.
Please sign in to leave a comment.