Scoring logic applies math to a variable you create inside a survey. The name suggests a running score built from answers across the survey, and that is the most common use. It also helps to think of it as a simple counter: each time a respondent picks a certain answer, the counter goes up (or down) by an amount you choose.
Learn more about Scoring and other types of advanced aytm Logic on the Lighthouse Academy!
In This Article
- Basic Scoring
- Scoring Operators
- Combining Score with Show Logic
- Scoring on the Results Page
- Tips and Common Mistakes
Basic Scoring
- With your questions and answers programmed, create the variable and give it a starting value in the text of a question that comes before the items you want to score, e.g.,
[concept = 0]. - In later questions, add logic to the answer options you want to score. Use the variable, a math operator (+ - * /), and a number, e.g.,
[concept + 1].
Logic typed on an answer option runs only when the respondent selects that answer. In the example below, the variable concept starts at zero. A respondent who selects Q2A1 adds 1 to concept, so their score becomes 1.
⚠️ Note: A variable's new value is ready from the next question on. Don't test a score in the same question that changes it.
You can also score from a later question instead of from the answer itself by adding a condition with if. For example, [concept + 1 if Q2A1] typed in the text of Q5 adds 1 when the respondent picked Q2A1.
Scoring Operators
| Logic | What it does |
|---|---|
[concept = 0] |
Sets the score to a value. Use it to give the variable its starting value. |
[concept + 1] |
Adds to the score. Use a bigger number to give an answer more weight, e.g., [concept + 2]. |
[concept - 1] |
Subtracts from the score, e.g., for a negative answer. |
[concept * 2] |
Multiplies the score. |
[concept / 2] |
Divides the score. The result can be a decimal. Dividing by 0 sets the score to 0. |
[concept] |
Typed in question or answer text, shows the respondent their current score. |
Variable names start with a letter and can contain letters, numbers and underscores. They are not case-sensitive, so Concept and concept are the same variable. For naming rules and reserved names, see Variables.
Combining Score with Show Logic
A common way to use scoring logic is to combine it with show logic. You can show questions or answers to a respondent based on the score they built up in earlier questions.
- Type
[show iffollowed by the variable name into the question or answer option. Then add a comparison operator and a number, e.g.,[show if concept = 4]. You can also usehide,skip, or other conditional logic with a score.
| Type | Meaning |
|---|---|
= |
equal to |
!= or <>
|
not equal to |
> / <
|
greater than / less than |
>= / <=
|
greater than or equal to / less than or equal to |
⚠️ Note: Type "greater than or equal to" as two characters,
>=. The single symbols ≥ and ≤ are not valid aytm Logic and are flagged as an error.
In the example below, respondents reach Q6 with a concept score between 0 and 4. Respondents whose score is exactly 4 see Q6. Everyone else goes on to the next available question.
Scoring on the Results Page
Once respondents have answered a survey that uses scoring logic, the variable is available on the Results page in two places:
- Filters: the variable is listed among the survey's variables, so you can filter results to respondents with a given score.
- Virtual Questions: you can turn the scores into a chart, as described below.
- On the Results page, open the Data Lab panel and drag a Virtual Question into place on your report.
- Click the Optional Presets drop-down and select your variable name from the Variables group.
- Adjust the answer options and groupings as needed, and click Generate visualization. The chart shows one answer option per score and how many respondents got each score.
⚠️ Note: The preset lists only the scores respondents actually got, not every score that was possible. A score nobody got gets no answer option. A respondent who never reached the question that sets the variable has no score and isn't counted in any answer option.
💡 Tip: If there are many different scores, group them into ranges. Edit each answer option's logic to a range, e.g.,
concept >= 0 and concept <= 3for "Low" andconcept >= 4for "High". You can also work with the variable in the raw data file.
Tips and Common Mistakes
- Set the starting value in question text, not on an answer. Logic on an answer runs only for respondents who pick that answer. Everyone who sees the question gets the starting value from the question text.
-
Don't put quotes around numbers.
[concept = "0"]makes the variable text, so[concept + 1]joins the characters instead of adding, and gives01. -
Use a different variable for each score. To score several concepts, give each one its own variable, e.g.,
concept_aandconcept_b. - A score you never set starts at 0. Adding to an unset variable starts from 0. Setting it to 0 at the start still matters, though, so that every respondent has a score on the Results page.