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 take it to the next level with complex random path assignments, piped responses, custom text, and hidden value calculations. 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 as soon as you open a square bracket [.
What do the colors mean?
When entering logic, you may notice text appears in different colors:
- Gray — logic is acceptable as written
- Blue — logic is acceptable at the moment (while editing)
- Orange — system detects a possible error; review before launching
- Red — logic is not valid; survey cannot be launched as written
- Black — system does not recognize this as logic; text will be shown to respondents
Learn more in the Lighthouse Academy!
Can I use multiple logic brackets in one field?
Yes — there's no limit to how many aytm Logic statements within their own brackets can be used in a field. Multiple [Show if…] and/or [Hide if…] statements are evaluated sequentially with AND logic applied between them. We recommend simplifying to a single [Show/Hide if…] statement where possible.
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 responses from Q1R and connect the last two with "or" instead of "and" |
| [Q7Ri] | Pipe the image associated with the 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 order of two top-level groups; within the first, 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 subquestion (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, separates multiple selections with commas and "and" |
| P | Position | Return rank order (Reorder, Side-by-Side) |
| V | Value | Return a data point such as R or P 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 element |
| 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 be read as text (non-numeric) |
| @... | Alias | Create hidden alias for question or answer; referenceable in logic |
| # | Hashtag | Link answer choices together for easier analysis in Virtual Questions |
| 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 requiring both criteria to be met |
| : | And (range) | Represent a consecutive range of terms with "and" |
| , | And | Separate non-consecutive terms with "and" |
| or | Or | Combine terms requiring either criteria to be met |
| - | Or (range) | Represent a consecutive range of terms with "or" |
| . | Or | Separate non-consecutive terms with "or" |
| not | Not | Apply inverse meaning to the 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 |
| >= | Greater Than or Equal To | Check if first term is greater than or equal to second |
| < | Less Than | Check if first term is less than second |
| <= | Less Than or Equal To | Check if first term is less than or equal to second |
| … if … | If Conditional | Define conditional criteria for logic to apply |
| ( ) | Logic Term | Group compound logic terms with parentheses |
| then | Then | Define a nested group in Group Logic |
Commands
| Syntax | Function | When to Use |
|---|---|---|
| Show if … | Show Item | Show question, subquestion, or answer if condition is met |
| Hide if … | Hide Item | Hide question, subquestion, or answer if condition is met |
| Hide if 1=1 | Always Hide | Always hide question, subquestion, or answer |
| Hide Text | Hide Text | Hide text of question, subquestion, or answer from respondents |
| Skip to … | Skip To | Skip to specified question if condition is met |
| Mask by … | Hide Items If Not Selected | Hide items not selected at a prior question. Applies to all options including "Other" and "None" — use with caution. |
| Rev-Mask by … | Show Items If Not Selected | Hide items selected at a prior question. Applies to all options including "Other" and "None" — use with caution. |
| Group … | Randomize Question Order | Specify questions or sets to be rotated in random order ("nodes"). See also: Balance, Max, RandFill. |
| Max … | Set Max Nodes to Assign | In Group logic, limit the maximum number of nodes per respondent; uses least-fill assignment by default |
| RandFill | Pure Random Assignment | In Group logic, use pure random node assignment instead of default least-fill |
| Balance … | Balance | In Group logic, balance nodes by specific subgroup criteria; separate subgroups by comma |
| Sort by a-z / z-a | Sort A–Z or Z–A | Sort answer options or subquestions alphabetically. Specify question number and element type (e.g. Q1A or Q1SQ). |
| Sort … by … | Sort by Array Order | Sort answer options or subquestions by an array of values. Specify element type (e.g. Q1A by… or Q1SQ by…). |
| Except … | Except Item(s) | Exclude specified answer options from Mask, Rev-Mask, or Sort logic |
| Glue … | Keep Items Together | Keep a set of answers or subquestions together during UI randomization. Use : or , (AND) to preserve order; - or . (OR) to randomize order within the group. |
| Show first # … | Show First # Items | Show only the first specified number of answers or subquestions. Combine with UI randomization for a random subset. |
| Show last # … | Show Last # Items | Show only the last specified number of answers or subquestions. Combine with UI randomization for a random subset. |
| Punch | Assign Answer or Value | Assign answers to respondents without them seeing the question |
| Rand #:## | Generate Random Number |
Generate a random whole number from the specified range. Assign
to a variable to store it (e.g. [randvar = rand 1:100]).
|
| Terminate if … | Terminate Respondent* | Terminate a respondent in PQs or within the first three survey questions when specific criteria are met* |
| Quota | Set Quota* | In PQs or the first three survey questions, set a quota for a certain answer option* |
*Terminate and Quota logic are available upon completion of the Custom Logic course in Lighthouse Academy. Contact your aytm Account Manager for details.
Scoring Calculations
Calculations can be performed and stored using custom variables, based on survey responses, other variables, or any specified value.
| Syntax | Function | When to Use |
|---|---|---|
| + | Addition | Add a value to another value |
| - | Subtraction | Subtract a value from another value |
| * | Multiplication | Multiply a value by another value |
| / | Division | Divide a value by another; returns a decimal |
| ** or ^ | Exponential | Raise a value to the power of another value |
| exp | Euler's Number (eˣ) | Raise Euler's number (e) to the power of a specified value; returns a decimal |
| round | Round |
[result = round 3.1415] → 3
|
| round2 | Round to decimal place |
[result = round2 3.1415] → 3.14
|
| ceil | Round up |
[result = ceil 3.1415] → 4
|
| floor | Round down |
[result = floor1 3.1415] → 3.1 (compatible with
floating point: [z = 0.1 + 1.1 + .1])
|
Arrays
Arrays are variables that hold multiple data points (up to 500) in one collection. Elements can be numeric and/or alphabetic. Arrays can be overwritten to apply functions (e.g. custarray = sort custarray).
| Syntax | Function | When to Use |
|---|---|---|
| << | Add | Add an element (numeric or text) to an array; separate multiple elements with a comma |
| |# | Array Element | Return the array element at the specified position |
| = shuffle | Randomize | Randomize the order of elements in the array |
| = reverse | Reverse Order | Reverse the order of elements in the array |
| = sort | Sort Ascending | Sort elements ascending: numbers least to greatest, then letters A–Z with capitals before lowercase (e.g. "1", "10", "100", "11", "Apples", "apples") |
| = reverse sort | Sort Descending | Sort elements descending: lowercase before capitals, letters Z–A, then numbers greatest to least |
| = unique | Remove Duplicates | Remove all duplicate elements from the array |
| in | Find Exact Element | Search for an exact element in the array (e.g. "apple" must match "apple" fully) |
| like | Find Within Element | Search for a partial match within array elements (e.g. "apple" within "red apple") |
| array_name = | Check Array Equality |
Check if arrays match regardless of item order (e.g.
arrayname=2,4 matches both 2,4 and 4,2)
|
| count array_name = | Count |
Check if array length equals a specified value (e.g.
count array_name=4)
|
| [join array by " or "] | Join with Word | Connect each item in the array with the specified word (e.g. "or") |
| [oxford-join array by "or"] | Oxford Join | Separate items with commas and connect the last two with the specified word (Oxford comma style) |