Use answers from previous questions (piping)

Use answers from previous questions (piping)

Piping means inserting a participant's earlier answer into the text of a later question — for example, greeting them by name or referring back to a choice they made. In LimeSurvey, you do this by giving the earlier question a question code and then referencing that code in curly brackets.

The recipe

  1. Assign a question code to the source question. Open the question, and in the Question settings panel on the right (Advanced tab), set the Question code field (e.g. name instead of the default Q001).
    • Codes must be unique within the survey and must not start with a number — use q1, not 1.
    • The code also becomes the variable name when you export data to SPSS or R, so short and meaningful is best.
  2. Reference it in a later question. In the text of any later question, type the code in curly brackets: {name}. When participants complete the survey, {name} is replaced with their answer.

That's it — no extra setup or activation needed. If the reference shows up literally as {name} in the survey, double-check that the code matches exactly (codes are case-sensitive) and that the source question comes before the one referencing it.

Tip: for questions with predefined answer options, {QCODE} inserts the answer code (e.g. Y). To show the answer text the participant saw (e.g. "Yes"), use {QCODE.shown}.

Example 1: greet the participant by name

  1. Question 1 — Short free text, code name, text: "What is your first name?"
  2. Question 2 — code age, text: "Nice to meet you, {name}! How old are you?"

A participant who typed "Maria" sees: "Nice to meet you, Maria! How old are you?"

Example 2: refer back to a choice

  1. Question 1 — List (radio), code product, asking which product the participant uses.
  2. Question 2 — text: "How satisfied are you with {product.shown}?"

If they picked "Cloud Backup", the follow-up reads: "How satisfied are you with Cloud Backup?"

You can also vary the wording with a simple condition. For example, if an earlier question has the code age, then {if(age < 18, 'your parents', 'you')} shows "your parents" when the participant answered under 18, and "you" otherwise. This is the same expression syntax used by the Condition designer ("New logic" in the Question settings panel).

Check that it works

Use Preview survey (the eye icon at the top right, next to Activate) to open the survey, answer the source question, then move to the page with the reference — the placeholder should show your answer. The reference only resolves in a running survey: it needs a participant's answer, so while you edit the question text on the canvas the placeholder stays as literal {name}.

Note that piping across questions on the same page updates live as the participant types; references to answers from previous pages are filled in when the page loads.

If you used the classic editor

The classic editor has a "lime between brackets" wizard button, which inserts references from a select box. In the new editor, the text toolbar's menu has a Placeholder fields entry — but it inserts participant and survey fields (name, email, survey ID and so on), not answers to previous questions. To pipe an answer, type the {code} reference directly into the question text.

Going further

Piping is the simplest use of LimeSurvey's expression engine. The same {...} syntax supports calculations, conditional text, validation, and much more — see the full ExpressionScript reference in the LimeSurvey manual.

    • Related Articles

    • Reorder, preview, and manage questions

      Once your questions exist, most day-to-day work happens in the survey editor: changing the running order, previewing the result, reviewing a question's setup, and reusing earlier answers in later questions. This article covers those tasks. For ...
    • Formatting text: the editor toolbar

      Click into any text in the survey editor — a question, help text, the welcome or end message — and a small floating toolbar appears above it. This is where all text formatting lives. The toolbar buttons Alignment — left, center, or right. B — bold ...
    • Insert Answer from Previous Question

      Insert answers from previous questions LimeSurvey allows you to insert answers from previous questions into the text of a question. You can refer to answers on the same page and even dynamically update tailored messages as responses change on the ...
    • Question and answer codes

      What codes are Every question, sub-question, and answer option in LimeSurvey has a short identifier — its code: Question codes — one per question, such as Q001. LimeSurvey assigns these automatically; you can rename them. Sub-question codes — one per ...
    • Validation: make sure the answers you get are usable

      Validation stops participants submitting an answer that cannot be right — a percentage over 100, an email address with no @, a budget split that does not add up. It is worth the effort: an answer you reject at the time is one you do not have to clean ...