In Snap you perform calculations and categorise received responses into codes, then use the results in later pages of your questionnaire. You can change text, add codes to questions and change which questions are shown.

This worksheet example tells you how to calculate how long someone waited to see a pharmacist and displays an apology if appropriate.

Background

In-survey calculations work on answers as the survey is being completed. Combine the results with text substitution (piping), routing (skip logic) and masking to change your live questionnaire; anything from what the text respondents see to the questions displayed.

You perform in-survey calculations in Snap using derived variables.

You can display the content of the derived variable in the questionnaire and/or show or hide other parts of the questionnaire depending on their value.

Derived variables are created from responses to other variables. The way you create them will be different for each type of derived variable.

For example, you could display a derived value in the questionnaire to:

  • add up costs to display a total (in a derived quantity variable)
  • add a title to someone’s name (in a derived literal variable).

If you want to change the content shown in the questionnaire, you can choose what to show by testing the value of a derived variable. You can:

  • change text depending on the result
  • show or hide questions and text depending on the result
  • use routing to jump to different parts of the questionnaire depending on the result.

See more ↓Hide this content ↑

Step 1: Create the derived variable to calculate the wait time

You can work out how long someone has had to wait for an appointment and display an apology if appropriate. You must create a derived variable to work out how long the wait was.

This example assumes that the appointment time is stored in Q1 and the time the respondent was seen (if later) is stored in Q2.

  1. Click Variables window button to display the Variables Window.
  2. Click New button to add a new variable.
  3. Specify the Variable details:
    Name: Delay.
    Label: Wait time to see pharmacist.
    Type: Derived (the variable will derive its data from the other time variables).
    Response: Quantity (the variable will hold a number of seconds).
    Smart reporting: image of
  4. Set the value for the Valid code to be Q2-Q1 to get the difference between the times. (Note that this calculation assumes that Q2 is greater than Q1.)
  5. Click save to save the variable.

Tell me how to do this ↓Hide this content ↑

Step 2: Create the derived variable to categorise the wait times

You can band the time into separate codes using another derived variable. This will provide the appropriate apology text (if necessary).

Times in Snap are stored in seconds. The derived variable calculates time ranges in seconds and bands the result.

  1. Click Variables window button on the Snap toolbar to display the Variables window.
  2. Click New button on the Variables window toolbar to add a new variable.
  3. Specify the Variable details:
    Name: delayband.
    Label: Delay codes used for apology.
    Type: Derived (the variable will derive its data from the Delay variable that you have just created).
    Response: Single (the data will be coded into bands).
  4. Double click in the first code label and enter appt time ok. This is a delay of less than ten minutes.
    Derived variable with insert button highlighted
  5. Press [Tab] to move to the Values column. Enter delay < 601. This is a delay of ten minutes or less.
  6. Press [Tab] to move to the next code label field and enter more than ten minutes. Then enter delay < 1200 as the Value. This is the range ten to twenty minutes. Since the codes are checked in order, a value less than ten minutes will already have been coded.
  7. Press [Tab] to move to the next code label and enter more than twenty minutes. Then enter delay < 3600 as the Value. This is the range twenty to sixty minutes.
  8. Press [Tab] to move to the next code label and enter more than an hour. Then enter true as the Value. This catches all numbers above 3600 seconds.
  9. Click save to save the derived variable.

The text in the code labels 2, 3 and 4 will be text substituted (piped) into the questionnaire when appropriate. It will not be necessary to show the text in code label 1 in the questionnaire.

Tell me how to do this ↓Hide this content ↑

Step 3: Use the code labels in your questionnaire

You can insert the label of a selected response in your questionnaire. In this example, you insert the apology text if the delay to see the pharmacist is over ten minutes or display appreciation text if the delay is ten minutes or under. These texts will be displayed in two instructions.

  1. Click Questionnaire window: design modeto change to the Questionnaire view.
  2. Go to the end of the questionnaire and press enter to create a new variable.
  3. Change the type to Instruction and type in first message text “That’s great, we aim to see all visitors within 10 minutes of their allotted appointment time.”
  4. Press enter to create another instruction.
  5. Insert the first part of the apology “We are very sorry to hear that you had to wait”
  6. Check the toolbar topic is set to Font, click the [Insert…] button on the Questionnaire window toolbar and select Variable Field from the menu.
  7. The New variable field dialog appears. Select delayband as the variable and Reply as the aspect.
    New vaariable field getting context aspect
  8. Click [OK]. Snap will display the question name within curly brackets {delayband}, to show that it is a text-substituted field.
  9. Add the text “Please accept out apologies.”
  10. Click save to save your changes.

Tell me how to do this ↓Hide this content ↑

Step 4: Show or hide the text depending on the responses

You can set when questions and instructions are to be displayed using routing conditions. Set conditions (skip logic) on your instructions so that the correct one is shown depending on the delay.

  1. Select your instruction for no delay and click Routing button on the Questionnaire window toolbar to open the Routing Rules dialog.
  2. Click [Add] to create a new rule and set the type to Conditionally Ask Question. Click [OK].
  3. Enter delayband = 1 in the If field and click [OK]. This instruction will be shown if they had to wait less than ten minutes.
    Routing Rules delayband If
  4. Select the instruction for the apology and add a new routing rule in the same way as in step 3 but this time set the If field to delayband > 1 and click [OK]. This instruction will be shown if they had to wait longer than ten minutes.

Tell me how to do this ↓Hide this content ↑

Step 5: Test your questionnaire

When you have set up your questionnaire, you should check it to make sure that it works the way you want.

  1. Publish the survey with Preview enabled.
  2. Click through the preview, entering different appointment times and times you were seen. Confirm that the apology appears with the correct text if the delay is between ten and twenty minutes, over twenty minutes or over an hour. Confirm that the appreciation appears if the delay is ten minutes or less.
    Preview with two time questions

Tell me how to do this ↓Hide this content ↑

Conclusion

This worksheet has described how to use a derived variable to decide which questions will be shown using routing. It also uses text substitution to insert dynamic text. .

The help includes two tutorials:

You can find out more about using derived variables to categorise responses in the section: Using derived variables.

You can see more about dynamic text in the topic: Inserting a previous response into the text of your questionnaire.

There is a worksheet on using routing to limit grid questions displayed. You can also find out more about routing in the help section: Introduction to routing.

If there is a topic you would like a worksheet on, email to snapideas@snapsurveys.com