Setting an initial value
An initial value can be set for a question. This value is selected or displayed as the default answer to the question, when a participant is completing the questionnaire. The Initial Value field can be set to a code, literal constant or an expression using values from the preceding questions, depending on the question style.
The initial value is set in the Variable Details window or Variable Properties window.
In the Variable Details window, the Initial Value field is shown when you click Toggle Definitions .
The Initial Value property is also available in the Variable Properties dialog opened from the Questionnaire window.
Note that the Initial Value is not available for Paradata variables or Note variables.
Using the Initial Value property
In this example, the questionnaire is set up to ask about the number of people in the participant’s party. The values that the participant enters can be used to set the initial value for a question about the number of people in the party who ordered food.
In this questionnaire, Q2 is an Open Series question asking for the number of adults and children in a group of people at a restaurant and Q3 is an Open Ended question asking how many people in the party ordered food. Usually everyone orders food so the default for Q3 is the total number of people in Q2.
The questions are created using the following step by step instructions:
- Open the survey in the Questionnaire window with Design mode set.
- Click New Question on the Questionnaire toolbar to insert a question.
- Select the Open Series style from the Style Selection Box on the toolbar.
- In the area marked “Click here for text”, enter “How many people were in your party today?”
- Click Variable Properties on the Questionnaire toolbar. This opens the Variable Properties dialog.
- In the Variable Properties change the
- Response: Quantity
- Label: Adults
- Insert another entry with the properties
- Response: Quantity
- Label: Children.
- Insert another Open Ended question to be used to show the number of people who ordered food. Again set the Response to Quantity.
- Click Variable Properties on the Questionnaire toolbar. This opens the Variable Properties dialog.
- Type Q2a+Q2b in the Initial Value to show the total number of people in the party. When an expression is used this automatically sets the Read Only property to Yes. Setting the Read Only property to Yes prevents a respondent overwriting or answering the question.
- This question needs to be on the following page so insert a page break above this question.
- When the questionnaire is running the participant enters the numbers in each question.
- On the next page of the questionnaire the total number of people is used as the default.