x

Main chapters

  1. Get started
  2. Workspace
  3. Editor
  4. Question types
  5. Share
  6. Results
  7. Configuration
  8. Installation and updates
  9. Profile and personal settings
  10. Account and billing
  11. FAQs
  12. Development
 Actions

Piping: use answers from previous questions

From LimeSurvey Manual

Piping puts an earlier answer into a later text, for example "What do you like most about your Laptop?" after a participant chose Laptop. You insert a placeholder with the question code in curly brackets, and LimeSurvey replaces it with the answer while the survey runs.

Insert an earlier answer

In the new editor

  1. Click the text of a later question where the answer should appear.
  2. In the toolbar above the text, click the ⋮ button (1) and point to Placeholder fields (2).
  3. Under Fields based on previous answers (3), click the question. LimeSurvey inserts a placeholder such as {Q001.shown} at the cursor.
  4. Preview the survey with Preview survey (the eye icon in the top bar), answer the earlier question and check the text.


Text toolbar in the new editor with numbered markers on the ⋮ button, Placeholder fields and the list Fields based on previous answers


The list of earlier answers is offered in question texts. In other texts, such as the help text of a question or the end screen, type the placeholder yourself.

In the classic editor

  1. Open the question and click Edit.
  2. In the toolbar of the question text, click Placeholder fields (the { } button).
  3. Under Previous answer fields, select the question and click OK. LimeSurvey inserts a placeholder such as {Alcohol.shown}.
  4. Click Save.


Placeholder fields dialog of the classic editor listing Previous answer fields with the Alcohol question selected


When the survey shows all questions on one page (All in one), the classic dialog only offers answers from earlier pages. You can still type the placeholder yourself.

Answer code or answer text

{Q001.shown} shows the answer the way the participant saw it, for example Laptop. {Q001} gives the answer code instead, for example A002. For text and number questions both give what the participant typed.

You can also type a placeholder yourself. The question must come before the text that uses it, and codes are case-sensitive. See Regenerate question codes.

In the editor, a placeholder stays as you typed it. It is replaced only in the running survey. If the earlier question is on the same page, the text updates as soon as the participant answers.

Insert participant and survey data

The same menu inserts data that is not an answer:

  • Participant email address, Participant first name and Participant last name (in the classic editor: Participant - Email address, Participant - First name, Participant - Last name) come from the participant list. Your own participant attributes are listed as Participant attribute: .... These fields stay empty for participants who open the survey through a public link.
  • Question ID, Question group ID, Survey ID and Survey expiration date come from the survey.

Vary the text

A placeholder can hold an expression. {if(Q001 == "A002", "laptop", "phone")} shows "laptop" to participants who chose the answer with the code A002 and "phone" to everyone else. See ExpressionScript Engine - Quick start guide.

FAQ

Why does my survey show {Q001} instead of the answer?

The code in the placeholder does not match a question before this text. Check the spelling and the upper and lower case of the code, and that the question comes earlier in the survey.

How do I greet invited participants by name?

Use Placeholder fields ⇒ Participant first name (classic editor: Participant - First name). It inserts {TOKEN:FIRSTNAME}. It is filled for participants you invite from the participant list, and empty for everyone who uses a public link.

See also