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
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!
@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:

!
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
What am I doing wrong?



!

!
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.
!

!

!



It still doesn't work...
Can you provide the preview link? if possible?
Here the preview link:

https://eu.qualtrics.com/jfe/preview/SV_819vlRMho3nJVQ1?Q_SurveyVersionID=current&Q_CHL=preview
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
I cannot open this link, how do I do that?
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

Leave a Reply