How to Filter Answers By Answers

Overview

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 these TV stations did you watch in the last year?"

2. "Which of these TV stations did you watch in the past 6 months?"

3. "Which of these TV stations did you watch in the past month?"

We will need that answers which were not chosen in question 1 will not appear in question 2.
Answers that 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:

We need the answers that were not chosen in question 1 will not appear in question 2.

So, only the Answers that were answered in Q6 will be displayed in Q7:

By adding the following start script to the question, we want to filter its answers:

FilterAnswersByAnswers(CurrQues,Q6);

Note: Q6 is the variable name of the question that the function refers to. You can refer to questions either by their variable name (recommended) or their index. You can refer to our scripting Best Practices Guide for more details. 

The function will filter question Q7 answers by the answers that were chosen in question Q6.

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(CurrQues,false,Q6);

*Notice: Changing the value from false to true is the same as the default function we saw previously.

For example, the answers that are chosen in question Q6 will be hidden in question Q7.

 

If you want to filter the answers of question Q8 based on the answers provided in questions Q6 and Q7, you can use the following code in the Start Script of Q8:

FilterAnswersByAnswers(CurrQues,Q6,Q7);

Best Practices

There are cases where you’ll need to perform several separate filtering commands in one question.

For example, Q6, Q7, and Q8 all have the same answers list.

The filtering logic for Q3 is as follows:
- Display only the brands that were chosen in Q6
- From those displayed brands – hide those that were chosen in Q7

You cannot perform all of the above in one function call, you’ll need to do it in stages. in Q8 start script:
- First, display all answers coded in Q6 this way:
FilterAnswersByAnswers(CurrQues, Q6);
- Now we want to hide the answers that were chosen in MOST_USED. In most cases, we would use this overload function this way:
FilterAnswersByAnswers(CurrQues, false, Q7);
But this would “cancel/reset” the first filtering call, because this function says: “hide only the answers that were chosen in MOST_USED and show all the rest”. This means, an answer that was hidden after the first filtering call (because it was not chosen in AWARE), will now be shown after the second filtering call and that’s not what we want (we want to hide the answers chosen in MOST_USED within the displayed answers that were chosen in AWARE).
To overcome this, use the third overload for this filtering method:
FilterAnswersByAnswers(CurrQues, false, false, Q7);


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 AWARE) will stay hidden after the second filtering call as we wish.

That’s it! 

Was this article helpful?
3 out of 3 found this helpful
Have more questions? Submit a request

Comments

2 comments
  • Hi Team,

    Please remove the project, I will start script, we will grateful to you.

    Thanks,

    0
    Comment actions Permalink
  • I am currently using this
    FilterAnswersByAnswers(CurrQues,true,true,QRef(17),QRef(18),QRef(100),QRef(101),QRef(102),QRef(103),QRef(104));

    And of course it shows me the options, but what I need is to have a condition for it to show it and that's what I don't know how to do.

    I need it to only be displayed when credit card is selected in the Q96 questions.

    0
    Comment actions Permalink

Please sign in to leave a comment.