This article describes how to use Search/Replace to change automatically change the Expression field in multiple variables.
Method
This is demonstrated using a Pick Any - Grid question called Q5. Brand associations in c:\Program Files\Q\Examples\cola.Q.
It is important to appreciate that this example is designed to illustrate the mechanics of using the Search/Replace function to modify expressions and a better way of doing the specific task demonstrated on this page is to use either a filter or QScript (in particular, see Rebasing Questions Using a Condition).
- In the Variables and Questions tab select the question to be copied.
- Right-click and select Copy and Paste Questions > Linked.
- Right-click and select Search/Replace : Formulas.
- Enter * in the Find what box (see wildcards for an explanation).
- Enter if (Q2 == 1) ${0}; else 0 in the Replace with box. Note that this will add "if (Q2 == 1); " before whatever is currently in the Expression field for each variable and "; else 0" at the end of the Expression. Thus, this example replaces the current value with a 0 if the respondent has a value of 1 in Q2 and otherwise it leaves the value unchanged.