aytm Logic Reference Guide
aytm Logic is a syntax that can be used to power up your surveys. You can customize respondents’ survey experience using simple logic such as [show if] or [mask by] commands, or you can take it to the next level and create complex random path assignments, pipe responses or custom text, and even assign and calculate hidden values. Download the PDF guide here.
How do I use aytm logic?
aytm Logic is written in [square brackets] and can be used in most text input fields in the survey editor. Turn on aytm logic autocomplete to be guided with suggestions by the platform as soon as you open a square bracket [ .
What do the colors mean?
When you're entering logic, you may notice that the text appears in a few different colors.
- gray = logic is acceptable as written
- blue = logic is acceptable at the moment (while editing)
- orange = system detects a possible error; review logic before launching
- red= logic is not valid, and survey may not be launched with logic as written
- black = system does not recognize this as logic text; text will be shown to respondents
Learn more about utilizing aytm Logic in our Lighthouse Academy courses!
Can I use multiple logic brackets in one field?
Yes, there is no limit to how many aytm Logic statements within their own brackets can be used in a field. If there are multiple sets of [Show if…] and/or [Hide if…] logic, they will be evaluated sequentially and will have AND logic applied between them. However, we recommend simplifying to one [Show/Hide if…] logic set.
Examples of aytm Logic
Statement |
What it does |
[Show if Q1SQ1A1] |
Show if selected A1 at SQ1 of Q1 |
[Show if Q2A1 or Q3A1-2] |
Show if selected (A1 at Q2) OR (A1 or A2 at Q3) |
[Show if Q4A6pv=1] |
Show if 6th item at Q4 was ranked first |
[Mask by Q5] |
Show corresponding items selected at Q5 |
[Q6R] |
Pipe the response from Q6 |
[replace Q1R from ",and" to ",or"] |
Pipe the responses from Q1R and connect the last two responses with “or” instead of “and” if there are multiple responses. |
[Q7Ri] |
Pipe the image associated with response from Q7 |
[Q8A3c] |
Pipe the open-ended comment from A3 at Q8 |
[“products” if Q9Rn>=2] |
Pipe “products” if selected 2+ items at Q9 |
[Group Q4-5 and Q6-7] |
Randomize the order (Q4-5) and (Q6-7) are shown |
[Group (Q2 then Q3 and Q4) and Q5)] |
Randomize the order the two high level groups are shown (Q2 then Q3 and Q4) and (Q5). Within the first group (Q2 then Q3 and Q4), randomize and show Q3 and Q4 after Q2 |
[Hide Text] |
Hide all text in field from respondents |
References
Syntax |
Represents |
When to Use |
Q# |
Question |
Reference question |
SQ# |
Sub-Question |
Reference sub-question (Matrix-based questions) |
A# |
Answer |
Reference answer option |
E# |
Entity |
For Quadrant and Topography questions, reference entity |
R |
Response |
Return response given at reference question; for checkbox, will separate multiple selections by “and” with commas as applicable |
P |
Position |
Return rank order (Reorder, Side-by-Side) |
V |
Value |
Return data point, such as R (response) or P (position), as numeric |
N |
Number |
For checkbox (multi-select), return the number of options selected |
C |
Comment |
Reference OE (open end) text box/field |
I |
Image |
Reference image associated with term |
X |
Expand |
For image, enable expanded image formatting |
S |
Scroll |
For image, enable vertical scrolling formatting |
‘ ’ or “ ” |
Text |
Single or double quotes for inputs to read as text (non-numeric) |
@... |
Alias |
Create hidden alias for question or answer; can reference in logic |
# |
Hashtag |
Link answer choices together for easier analysis in VQs |
vr_collected
|
video responses collected |
Will be true if the respondent submitted a video |
Delimiters/Operators
Syntax |
Represents |
When to Use |
and |
And |
Combine terms with requirement of meeting both criteria |
: |
And |
Represent a range of terms with a delimiter of “and” |
, |
And |
Separate terms with a delimiter of “and” |
or |
Or |
Combine terms with requirement of meeting either criteria |
- |
Or |
Represent a range of terms with a delimiter of “or” |
. |
Or |
Separate terms with a delimiter of “or” |
not |
Not |
Apply inverse meaning to immediately following term |
= |
Equal |
Check if two terms are equal |
!= |
Not Equal |
Check if two terms are not equal |
> |
Greater Than |
Check if first term is greater than second term |
>= |
Greater Than or Equal To |
Check if first term is greater than or equal to second term |
< |
Less Than |
Check if first term is less than second term |
<= |
Less Than or Equal To |
Check if first term is less than or equal to second term |
… if … |
If Conditional |
Define conditional criteria to be met for logic to apply |
( ) |
Logic Term |
Define compound logic terms grouped by parenthesis |
then |
then |
Define a nested group in Group Logic |
Commands
Syntax |
Function |
When to Use |
Show if … |
Show Item |
Show question, sub-question, or answer if logic condition met |
Hide if … |
Hide Item |
Hide question, sub-question, or answer if logic condition met |
Hide if 1=1 |
Always Hide |
Always hide question, sub-question, or answer |
Hide Text |
Hide Text |
Hide text of question, sub-question, or answer |
Skip to … |
Skip To |
Skip to specified question if logic condition met |
Mask by … |
Hide Items If Not Selected |
Hide items not selected at prior question; Applies to all options, including “Other” and “None” options so use with caution |
Rev-Mask by … |
Show Items If Not Selected |
Hide items selected at prior question; Applies to all options, including “Other” and “None” options so use with caution |
Randomize Question Order |
Specify questions or sets of questions to be rotated and presented in a random order, commonly referred to as “nodes” See also Balance, Max, RandFill for optional sub-commands |
|
Max …. |
Set Max Number Of Nodes To Assign |
In Group logic, optional command to limit the maximum number of nodes to be answered by any given respondent; by default, least fill assignment is used with “Max” limit to prioritize assigning nodes that have been answered by fewer total respondents |
RandFill |
Pure Random Assignment |
In Group logic, optional command to use pure random assignment to nodes instead of the default least fill assignment |
Balance … |
Balance |
In Group logic, optional command to balance nodes by specific subgroup criteria; separate subgroups by “,” (comma) |
Sort by a-z / Sort by z-a |
Sort Items From A to Z or Z to A |
Sort answer options or sub-questions from A to Z or Z to A Must specify question number and if elements to be sorted are answer options (e.g., Q1A) or sub-questions (e.g., Q1SQ) |
Sort … by … |
Sort Items By Array Order |
Sort answer options or sub-questions according to array of values Must specify question number and if elements to be sorted are answer options (e.g., Q1A by…) or sub-questions (e.g., Q1SQ by…) |
Except... |
Except item(s) |
Exclude specified answer option(s) of the current question from Mask, Rev-Mask, or Sort logic rules |
Glue … |
Keep Items Together |
Specify a set of question answer options or sub-questions to be kept together, or glued, when UI randomization is used Separate by “:” or “,” (AND term) to keep glued items in order Separate by “-” or “.” (OR term) to randomize order of glued items |
Show first # … |
Show First # Items |
Show only the first specified number of answer or sub-questions Combine with UI randomization to randomly show subset of items |
Show last # … |
Show Last # Items |
Show only the last specified number of answer or sub-questions Combine with UI randomization to randomly show subset of items |
Punch |
Assign answer or value |
Assign answer(s) for respondents without them having to see the question |
Rand #:## |
Generate Random Number |
Generate a random whole number from the specified range For this value to be stored in the dataset for later reference, it needs to be assigned to a variable (e.g., [randvar = rand 1:100]) |
Terminate if... |
Terminate respondent* |
Terminate a respondent in PQs or within the first three questions of a survey, when they meet specific requirements.* |
Quota |
set quota for answer option* |
In PQs or in the first three survey questions, set a quota to be fulfilled for a certain answer option.* |
*Terminate and Quota logic available upon completion of the Custom Logic course in Lighthouse Academy. Contact your aytm Account Manager for more details.
Scoring Calculations
Calculations can be performed and stored using custom variables. These calculations can use values based on survey responses, other custom variables, and/or any other specified value.
Syntax |
Function |
When to Use |
+ |
Addition |
Add a value to another value |
- |
Subtraction |
Subtract a value from another value |
* |
Multiplication |
Multiple a value by another value |
/ |
Division |
Divide a value by another value; creates fractional value (decimal) |
** or ^ |
Exponential |
Raise a value to the power of another value |
exp |
Euler’s Number (ex) |
Raise Euler’s number (e) to the power of a specified value; |
round |
Round a number |
Round a decimal: [result = round 3.1415] will result in 3. |
round2 |
Round a number |
Round a decimal to decimal to specific decimal point: [result = round2 3.1415] will result in 3.14. |
Ceil |
Round a number |
Rounding down a number: [result = floor 3.1415] will result in 3. |
Floor |
Round a number |
Rounding down a number to a specific decimal place: [result = floor1 3.1415] will result in 3.1 and is compatible with floating point numbers [z = 0.1 + 1.1 + .1] |
Arrays
Arrays are a type of variable that can hold multiple data points (up to 500) in one collection. Items in an array are often referred to as “elements” and can be numeric and/or alphabetic in nature. Arrays can be overwritten to apply desired functions below (e.g., custarray = sort custarray).
Syntax |
Function |
When to Use |
<< |
Add |
Add an element, numeric or text, to an array; separate multiple elements by comma |
|# |
Array Element |
Return array element in specified position |
= shuffle |
Randomize |
Randomize order of elements of specified array |
= reverse |
Reverse Order |
Reverse the order of elements of specified array |
= sort |
Sort |
Sort the order of elements of specified array in ascending order. Sorts individual numbers from least to greatest followed by letters from “A” to “z” where capitalized letter are sorted before lowercase letters (e.g., “1”, “10”, “100”, “11”, “Apples”, “Kiwi”, “apples”, “kiwi") |
= reverse sort |
Reverse Sort |
Sort the order of elements of specified array in descending order. Functions opposite of “sort” as above. Sorts letters from “z” to “A” where lowercase letters are sorted before capital letters followed by individual numbers from greatest to least (e.g., “kiwi”, “apples”, “Kiwi”, “Apples”, “11”, “100”, “10”, “1”) |
= unique |
Remove Duplicates |
Remove all duplicate elements of specified array |
in |
Find Exact Element |
Search for exact element within specified array; must match within the array completely and element in full (e.g., “apple” to “apple”) |
like |
Find Within Element |
Search for element within specified array that matches completely and element at least in part; (e.g., “apple” within “red apple”) |
array_name= |
Check if array is equal to something |
check if arrays match ignoring order of the items (e.g., arrayname=2,4 will show respondents with values 2,4 and respondents with values 4,2) |
count array_name= |
Count |
Check if the length of the array is a certain value (e.g., count array_name=4) |
[join array_name by ” or “] |
Connect each item in the array with the word “or”. |
When you want to connect each item in an array with “or” |
[oxford-join array_name by “or”] |
connect each item in the array with a comma and connect the last two items with “or”. |
When you want to create a list that separates the last two items with "or". |
PDF version
Save a copy of this information for reference - download the PDF.
Additional Resources
- Check out our other articles on ways to use aytm Logic.