Virtual Questions in Data Lab can use the codes and codebooks from your open-ended coding to quantify respondents, build charts, and filter survey data. Use a Codebook preset to generate a Virtual Question automatically, or write the logic yourself in advanced mode.
In This Article
- Virtual Question Presets
- Manually Create Virtual Questions using Codes
- Manually Create Virtual Questions using Codebooks
- Logic for Codes and Codebooks
Virtual Question Presets
Codebook presets automatically generate a Virtual Question from a codebook, with one answer for each code—a quick way to set up correlation analysis without writing logic.
- On the Results page, click the Data Lab tab in the left menu.
- Click the Virtual Question bar to add a Virtual Question to your report, or drag it into place between questions.
- Click the Optional Presets drop-down menu, and scroll to Codebooks.
- Select the entry you want. Each entry is listed as Q#: Codebook name, so a codebook used on more than one question appears once for each question.
- Click Generate Visualization.
The preset creates one answer for each code in the codebook, plus a Not coded answer for responses that weren't coded.
💡 Tip: Don't see your codebook? A codebook appears in the presets list only for questions where at least one of its codes has been applied to responses. Code some responses on that question first, then reopen the menu.
⚠️ Note: If you rename a code or codebook, any Virtual Questions that use it update automatically. If you delete a code, the logic that references it stays in place and that answer drops to 0—edit or remove the answer in any Virtual Question that used the deleted code.
Manually Create Virtual Questions using Codes
- On the Results page, click Data Lab, then click the Virtual Question bar or drag it into place in your report.
- Click Switch to advanced mode along the top of the A1. text box.
- Click into the A1. field.
- Type the logic as
tag Q# = 'Codebook name: Code name', whereQ#is your question number, followed by an equals sign, then the codebook name and code name separated by a colon and a space, all enclosed in single quotes. For example:tag Q2 = "Other Pet Types: Small mammals: Rabbit & Guinea pig" - Enter a label for your A1 code in the field to the right.
- Add a code in the A2. field the same way.
- Click Generate Visualization to generate the chart. This lets you quantify respondents, build charts, or filter the survey data based on specific codes.
⚠️ Important: The codebook and code names must match exactly, including the space after the colon. Capitalization doesn't matter, but
'Other Pets:Rabbit/Bunny'(no space) matches no responses and won't update if the code is later renamed.
Once the stats update, you can see the word cloud and the open-ended comments.
💡 Tip: To see the word cloud and comments for a code, include the question number where those responses appear (e.g.,
tag Q2 = ...rather thantag = ...). The system uses the question number to know which responses to pull.
Manually Create Virtual Questions using Codebooks
- On the Results page, click Data Lab
- Click the Virtual Question bar or drag it into place in your report.
- Click Switch to advanced mode along the top of the A1. text box.
- Click into the A1. field. Type the logic as
codebook Q# = 'Codebook name', whereQ#is your question number, followed by an equals sign, then the codebook name enclosed in single quotes. For example:codebook Q2 = 'Pet Types' - Enter a label for your A1 codebook in the field to the right.
- Add a codebook in the A2. field the same way.
- Click Generate Visualization or Update Visualization to (re)generate the chart. This lets you quantify respondents, build charts, or filter the survey data based on specific codebooks.
Once the stats update, you can see the word cloud and the open-ended comments.
💡 Tip: To see the word cloud and comments for a codebook, include the question number where those responses appear (e.g.,
codebook Q26 = ...rather thancodebook = ...).
Logic for Codes and Codebooks
Use these patterns in advanced mode, replacing the question numbers and names with your own. Code values always use the format 'Codebook name: Code name', with a space after the colon.
Codes
| To match | Logic | Notes |
|---|---|---|
| One code on one question |
tag Q1 = 'Codebook name: Code name'
|
Also accepted: Q1 tag = 'Codebook name: Code name'
|
| One code on any of several questions (or) |
tag Q1,Q2 = 'Codebook name: Code name'
|
The comma works as or. With multiple questions,
the question list must come after tag.
|
| One code on every listed question (and) |
tag Q1 = 'Codebook name: Code name' and tag Q2 = 'Codebook name: Code name'
|
Write out each question and join them with and. |
| Any of several codes on one question |
tag Q1 in 'Codebook name: Code A', 'Codebook name: Code B'
|
Matches responses with at least one of the listed codes. |
Codebooks
| To match | Logic | Notes |
|---|---|---|
| A codebook on any question |
codebook = 'Codebook name'
|
Without a question number, the word cloud and comments won't display. |
| A codebook on one question |
codebook Q1 = 'Codebook name'
|
Also accepted: Q1 codebook = 'Codebook name'
|
| A codebook on any of several questions (or) |
codebook Q1 = 'Codebook name' or codebook Q2 = 'Codebook name'
|
Write out each question and join them with or. |
| A codebook on every listed question (and) |
codebook Q1 = 'Codebook name' and codebook Q2 = 'Codebook name'
|
Write out each question and join them with and. |
⚠️ Note: The comma shortcut (
Q1,Q2) works only withtag. For codebooks, write out each question and join them withor. Every expression also needs thetagorcodebookkeyword—Q1 = 'Codebook name'on its own isn't valid logic.