Filters selected from the drop-down menus below a table apply to the whole table. In some cases, you may wish to filter the rows of a table using a different filter for each row. One example may occur when each row of the question represents a brand and you wish to filter each by respondents who use that brand. When the filter condition is satisfied, the new variable will take the same value as the old variable. When the filter condition is not satisfied, the new variable will be assigned a missing value. This removes the respondents who do not satisfy the filter from the base. In this case, there are a couple of solutions to get you a new question where each variables has the appropriate filter built in. This concept can apply to other question types with multiple variables such as Number-Multi.
Method 1: Using Filter One Question by Another
See Automate > Browse Online Library > Filtering > Filter One Question by Another Question in How to Rebase Questions.
Method 2: Using a Rule
You can filter rows and columns of a table using Filtering - Apply Filters to Columns or Rows. However, this will turn off statistical testing. If you require statistical testing, see Method 2.
Method 3: Manually creating Filtered Variables
This is essentially how to manually do what Method 1 does automatically. The example below shows you how to construct a new copy of a Pick One - Multi question in this way using the Cola.Q example project from your Examples folder. However, the same approach can be used with other Question Types. The Pick One - Multi question will be Q6. Brand Attitude and each brand in the question will be filtered by respondents who drink that particular brand weekly, according to Q9. Cola weekly. To test this example you should:
- Open C:\Program Files\Q\Examples\Cola.Q (this may be located on a different place on your computer depending upon how Q was installed).
- Go to the Variables and Questions tab.
- Highlight all of the variables from the Pick One - Multi question Q6. Brand Attitude.
- Right-click and select Copy and Paste Questions: Linked. This will create a new copy of the question below.
- Right-click on the first variable in the new question (Coca Cola) and select Edit Variable. (Make sure that you only have the first variable selected.)
- Change the text in the Expression box to the appropriate expression for Coca Cola that is listed below.
- Click OK.
- Repeat the previous three steps for each variable in the question, substituting the appropriate Expression from below.
- Change the entry in the Question column to Q6. Brand Attitude - Filtered by Weekly Drinkers.
- Coca Cola
if (Q9_A_3) Q6_A; else NaN;
- Diet Coke
if (Q9_B_3) Q6_B; else NaN;
- Coke Zero
if (Q9_C_3) Q6_C; else NaN;
if (Q9_D_3) Q6_D; else NaN;
- Pepsi Light
if (Q9_E_3) Q6_E; else NaN;
- Pepsi Max
if (Q9_F_3) Q6_F; else NaN;
- The if statement in each formula checks the relevant variable from Q9. Cola weekly to see if the respondent is counted as a weekly drinker of that brand.
- The second line assigns a missing value or NaN. This removes the respondent from the base for this variable, effectively filtering them.
- In this example you can apply the new filter for the first variable and then right-click it and choose Insert Ready-Made Formulas: Use as Template for Replication as a shortcut. However, this may not apply in all cases as it relies on a common structure for the two questions involved. See Use as Template for Replication for more details on using this feature.