How to Filter the Rows of a Table
Method 1: 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 2: Creating Filtered Variables
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.
- Filtering - Filter One Question by Another Question.
- Filtering - Apply Filters to Columns or Rows.