How to hide text based on previous answer | XM Community
Skip to main content

Hi community,
I am hopelessly new in Qualtric and need your help. I need to create a information page summing up some of your previous answers. Some answers are meaningless to include, whereas others are needed. So I would like a syntax saying:

  • IF Q15 >0 then display "Ungdom 349,- = ${q://QID5/ChoiceGroup/SelectedChoices}"

  • IF Q15= 0 then hide "Ungdom 349,- = ${q://QID5/ChoiceGroup/SelectedChoices}"

Best,
Lise

Your question is not clear. What I get from it is that you want to show the respondents their answers at the end. However, you want to show only a few answers.
If that is the case, and the number of conditions is small, you can simply create multiple Descriptive Text type questions and use display logic to show the one's that are appropriate.
If there are too many conditions, then you could use Embedded Data to record the answers you want, and then only display these at the end.


I am not quite sure if I understand completely. I'll try to explain one more time in more words.
In Q15 you can answer a numeric number between 0-4. I want to showcase some text And the results of the answer if they have answered 1-4.
If they have answered 0 i would like to not show text or results.

  • IF Q15 >0 then display "Ungdom 349,- = ${q://QID5/ChoiceGroup/SelectedChoices}"

  • IF Q15= 0 then hide "Ungdom 349,- = ${q://QID5/ChoiceGroup/SelectedChoices}"

It could be solved with several questions and display logic, but it is messy because there are three questions I want to build this logic for. So it would be great with a solution showing and removing text in the actual question.
Best,
Lise


Hide_Show_Text__JS.qsfAt Q1 I have added a JavaScript which capture the response from Q1 and based on response you can assign "value" in an embedded data and then display the embedded data in following question...
For now, in attached qsf, if anyone select 1 or 2 or 3 or 4, embedded data text value is "True" else it shows "false".... You can update it as per your requirement.


https://www.qualtrics.com/community/discussion/comment/32462#Comment_32462Showing and removing text in a question can be done through JS. However, the exact code will depend upon what type of questions you are using earlier. If you are comfortable with JS, then the flow would be simply to have a base text, which you will display for all choices, then based on the options chosen in the earlier questions, you append the relevant text and change what your are displaying with

jQuery("#"+
this
.questionId+" .QuestionText").html("Results Summary");

If on the other hand, you are not comfortable with JS, here is how I would recommend going about it.
  • For each of the questions, 3 in your case, create an embedded data field which carries the summary for each answer you want to display at the end. Let call them "Sum1", "Sum2" and "Sum3". Make sure they are empty at the start.

  • In the survey flow, after each of the questions, create a branch and set its condition to be something like
    ${q://QID5/ChoiceGroup/SelectedChoices} is not equal to zero

  • In this branch, set your relevant embedded variable to whatever you want to display at the end. In the example you have given, you will probably set
    Sum1
    to
    Ungdom 349,- = ${q://QID5/ChoiceGroup/SelectedChoices}

  • In the summary question (at the end). Display the general text and use piped data to show the answers that make sense. For example:




These are the options you have chosen:
${e://Field/Sum1}
${e://Field/Sum2}
${e://Field/Sum3}
If the fields are blank or unset, Qualtrics will display nothing. If they have a value Qualtrics will display that.


Hi Lise_Kristiansen - I wanted to hop in here and let you know that this can also be accomplished without a Custom Code solution! If you have not yet already, we'd recommend taking a look at this support page about our Display Logic feature. You can create a new block with all of the content you may want to display to a user, and then use Display Logic to only show the content specific to each user. If you have any follow up questions about this setup, please be sure to reach out to our wonderful Support team!


Leave a Reply