How do I use a part of the answer of a previous question as an answer in a following question? | XM Community
Skip to main content
Solved

How do I use a part of the answer of a previous question as an answer in a following question?

  • April 26, 2018
  • 10 replies
  • 496 views

So my first question is: Whats your name? Then in a following question I want to ask: In which stock would you invest? An I want to give the 5 choices of stocknames, 4 fixed names and one that starts with the first three letters of the name they entered in the first question, followed by -ment. So my name is MICHAEL, thus there should be one stock named 'MICMENT' in the second question. Please help me out!

Best answer by MohammedAli_Rajapkar

Hi @miga12 You can try adding below JavaScript at the on unload of "your name" question section Assign the response of "your name question" to "str" also create an embedded data with any name and replace "first3letter" with the embedded data name which you create. var str = "${q://QID1/ChoiceTextEntryValue}"; var res = str.substr(0, 3); Qualtrics.SurveyEngine.setEmbeddedData("first3letter",res); Then use the embedded data to piped-text on the 4th option of your next question

10 replies

2baprogrammer
Level 2 ●●
Forum|alt.badge.img
  • Level 2 ●●
  • 10 replies
  • April 26, 2018
@miga12 So I have a thought on this, in Qualtrics you can create a new block with a text entry question. then below create a multiple choice question with your 4 fixed names and the 5th would be to right click and choose insert piped text, insert from a survey question, choose the "what name" question you created and at the end of this code, add "ment" - ${q://QID135/ChoiceTextEntryValue}ment. The part I'm not sure about is how you would pipe in only a fixed amount of characters from the previous question. Does anyone else have thoughts on this? Screenshot below is of my setup for this: !

MohammedAli_Rajapkar
QPN Level 5 ●●●●●
Forum|alt.badge.img+20
  • QPN Level 5 ●●●●●
  • 482 replies
  • Answer
  • April 26, 2018
Hi @miga12 You can try adding below JavaScript at the on unload of "your name" question section Assign the response of "your name question" to "str" also create an embedded data with any name and replace "first3letter" with the embedded data name which you create. var str = "${q://QID1/ChoiceTextEntryValue}"; var res = str.substr(0, 3); Qualtrics.SurveyEngine.setEmbeddedData("first3letter",res); Then use the embedded data to piped-text on the 4th option of your next question

  • Author
  • 4 replies
  • May 4, 2018
What am I doing wrong? ! !

MohammedAli_Rajapkar
QPN Level 5 ●●●●●
Forum|alt.badge.img+20
you will have to add embedded data element in survey glow and name it as "first3letter". Then pipe-in the embedded-data in the option text.

  • Author
  • 4 replies
  • May 10, 2018
! ! ! It still doesn't work...

MohammedAli_Rajapkar
QPN Level 5 ●●●●●
Forum|alt.badge.img+20
Can you provide the preview link? if possible?

  • Author
  • 4 replies
  • May 10, 2018
Here the preview link: https://eu.qualtrics.com/jfe/preview/SV_819vlRMho3nJVQ1?Q_SurveyVersionID=current&Q_CHL=preview

MohammedAli_Rajapkar
QPN Level 5 ●●●●●
Forum|alt.badge.img+20
Hi @miga12 You will have to put the code before the question where you want it to pipe-in. For example: if I want to pipe-in Q1 data in Q3 then I will put the javascript code in Q2. To capture the answer from Q1 the javascript needs it to be before Q3. Here is the QSF for example: https://drive.google.com/file/d/1ATT1cgA00XU3PMTCOgi2XKELFtehAuLK/view?usp=sharing

  • Author
  • 4 replies
  • May 15, 2018
I cannot open this link, how do I do that?

MohammedAli_Rajapkar
QPN Level 5 ●●●●●
Forum|alt.badge.img+20
It's a file. When you click on this link you will see a button "Download" please click on "Download". Once the file is downloaded you can create a new project as "Create from Existing" and "From a file" importing this file in Qualtrics. Once it imported take a preview link and check the 3rd question for your pipe-in from the 1st question. Here is the survey preview link: The 3rd question first option have the response first 3 letter piped-in with additional text ("whichever text we want to append). In this example, I have appended "check". https://qimpl.az1.qualtrics.com/jfe/preview/SV_9AKORjSLfgoYsCx?Q_SurveyVersionID=current&Q_CHL=preview