Lesson 2.6

Lists, loops and variables

Ask the same questions about many items without copying them, and personalize text with merge fields.

9 min readLesson 9 of 34

In this lesson

  • Set up a list and loop a page over it
  • Loop over the items a respondent picked
  • Pipe values into text with variables

Many studies ask the same questions about several things: each brand a person uses, each ad they saw, each product in a range. Copying the questions for every item is slow and error-prone. Baxly uses lists and loops instead.

Lists

A list is a small table of items, with columns such as name, image, category or page number. Lists live under Lists & variables > Lists. Make one with + New list, paste it from a spreadsheet or upload an Excel or CSV file, Copy from another survey, or keep favorites in your library (Save to library, From your library). A list can feed a question's choices, a grid's rows, or a loop.

A list with an Image column shows as a Table or as Tiles, with a search box, category chips and a Missing images filter. Upload pictures one at a time on a tile, or many at once (Upload images, one item per image): a picture named like an item lands on that item. Each PNG, JPEG or WebP picture opens a crop step first, with Trim white space, and you can Upload original instead.

Loops

A loop repeats a page, or a single question, once per item. On a page, + Page options > Loop this page over a list opens Repeat this page for... with three sources:

SourceRepeats for
Each item of a listEvery item in the list.
The same items shown on another pageThe same items another loop resolved to, so two loops stay in step.
Each item the respondent picks in a questionOnly the items the respondent picked in an earlier question whose choices come from a list, optionally capped at the first N.

Inside a looped page, insert {{item.Column}} to show the current item's value, such as its name or picture. A page loop can show one item at a time, a few per page, or all on one page. A loop can also take a random or balanced sample of the items, always include certain items, and set the order: list order, reversed, shuffled, the same order as another loop, or Fewest completes first, which fills the least-answered items first.

Several pages can repeat together as one block. On the block's first page choose + Page options > Repeat several pages as one block: pick which pages repeat together, what they repeat for, and the pause between items. Respondents see every page of the block for one item, then a question asks whether to do another, then the block again. You set that question's wording, its two buttons, and whether reaching the end of an item counts as a complete. A bar above each block page reads Block with the page numbers and an Edit button, and the outline indents the pages inside the block.

Try it

A page that repeats

Repeat this page for

Q1Which of these do you ride?

The looped page as you type it

How often do you ride your {{item.Name}}?

The page repeats 2 times:

  1. Time 1

    How often do you ride your Road bike?

  2. Time 2

    How often do you ride your City bike?

Variables

Variables are merge fields you can put into any text, under Lists & variables > Variables. A survey variable is written {{var.Name}}. It can hold a fixed value you set, or Fill from the link: take its value from a parameter on the survey link, optionally limited to listed values, which is how a campaign tells the survey who someone is or where they came from. A text or email question can also start with that value already in the box: pick the variable under the question's Pre-filled answer setting, and the person sees it and can change it. Built-in tags come free, from the question editor's Insert auto-fill text... menu: {{year}}, {{last_year}}, {{next_year}}, {{today}}, {{date}}, {{month}}, {{month_year}}, {{quarter}} and {{survey}}. The year, month and quarter tags are dated at the survey's first publish, so a wave reads the same from its first respondent to its last and its results never change; a copy for the next wave moves on when it is published. {{today}} and {{date}} are the day the person answers. Variable rules set a value per respondent based on their answers ("set Segment to Heavy when..."); rules run top to bottom and a later match overrides an earlier one. A rule's value can be {{answer}}, the person's own answer to the question the rule tests, which is how a typed answer appears in a later question. Variables can also drive logic, and Results and review copies show them filled in.

Try it

An answer shown in a later question

Variable Bike starts as “bicycle”. Variable rules:

  • Set Bike to “road bike” when Q1 is “Road bike”
  • Set Bike to “mountain bike” when Q1 is “Mountain bike”
  • Set Bike to “city bike” when Q1 is “City bike”

Q1Which bicycle do you ride most?

Q2 as you type it

What do you like most about your {{var.Bike}}?

Q2 as the person sees it

What do you like most about your bicycle?

Knowledge check

You want a page to repeat only for the brands a respondent said they use. Which loop source do you choose?

Knowledge check

Two variable rules both match a respondent. Which value wins?

Key takeaways

  • Lists hold items, and pictures with a crop step; loops repeat a page, a question, or a block of pages per item.
  • Loop from a list, from another loop, or from the respondent's own picks, with samples and ordering if you need them.
  • {{var.Name}}, link-filled variables and the built-in tags personalize text; variable rules set per-respondent values in order.