Display question based on number of answer choices | XM Community
Skip to main content
Solved

Display question based on number of answer choices

  • January 14, 2025
  • 9 replies
  • 71 views

Forum|alt.badge.img+1

Hello,

I want to display a question only if there are a certain number of answer choices displayed in that same question. The answer choices are carried forward from multiple previous matrices. The matrices have five scale points, and only statements selected with the highest scale point are carried forward to that question. I only see display logic for selected count, but not for displayed count. Would anyone be able to help me with this?

Best answer by TomG

@DP24,

I would take a completely different approach: one question in which you use JS to change the question text based on how many rows are displayed.  It simplifies everything. 

Your question text would be something like:

<div class="qt qt1">Question text for one row</div>
<div class="qt qt23">Question text for two or three rows</div>
<div class="qt qt4">Question text for four rows</div>

JavaScript would be something like this (would be different for Simple layout):

Qualtrics.SurveyEngine.addOnload(function() {
	var q = jQuery(this.questionContainer);
	q.find(".qt").hide();
	var rows = q.find(".ChoiceRow").length;
	if(rows<2) q.find(".qt1").show();
	else if(rows<4) q.find(".qt23").show();
	else q.find(".qt4").show();
});

If your follow-up is a multiple choice instead of a matrix, just replace .ChoiceRow with .Selection.

View original

9 replies

Aggarwal
Level 4 ●●●●
Forum|alt.badge.img+15
  • Level 4 ●●●●
  • 134 replies
  • January 14, 2025

You can apply display logic based on displayed items. 


Forum|alt.badge.img+1
  • Author
  • 3 replies
  • January 14, 2025

I don’t want the display logic to be based on specific statements in the answer choices though. The question should appear only if a certain number of statements are present as answer choices, regardless of what the answer choices are. For example, the question will display if only one answer choice is displayed (so in this case, only one statement out of all the statements in the previous matrices was answered with the highest scale point).


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5921 replies
  • January 14, 2025

You can display the question if the count of the highest scale point is greater than zero in the previous questions. For example:

Question Q1 5 (Count) Is Greater Than 0

OR Question Q2 5 (Count) is Greater Than 0


Forum|alt.badge.img+1
  • Author
  • 3 replies
  • January 14, 2025

Hi ​@TomG 

Thank you for you help! The issue is that with this approach, the question will still appear if one or more answer choices that we are looking for (the highest scale point) is chosen for each matrix. I’m trying to make multiple questions that will have different language based on how many answer choices are displayed. So if only one statement out of all of the matrices is chosen with the highest scale point, then only that answer choice will display, and since there is only one answer choice, the wording of the question will be different than if two answer choices are displayed (so I’d make another question for this case), etc. 


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • January 14, 2025

@DP24 Based on your question and comment, its a little difficult to understand what you are aiming for. Perhaps it would help if you could give some examples. Maybe a few images to show what you mean.


Forum|alt.badge.img+1
  • Author
  • 3 replies
  • January 15, 2025

 

Hi ​@ahmedA 

Hope this clarifies my question a bit more:

I have three matrices each with five statements and five scale points (1-5), and then I have the question after the matrices. I will be pulling all statements from the three matrices that were chosen with a scale point of 5 (the highest rating) as answer choices for Question after matrices. However, I will be making several questions that does this (so there will be three separate Question after matrices, in this case denoted as V.1, V.2, and V.3). One question will only display if the total number of answer choices for that question is 1 (in other words, only one statement in all the previous matrices combined was marked with a scale point of 5). Another question will only display if the total number of answer choices is between 2-3 (so 2-3 statements in the previous matrices combined were marked with a scale point of 5). The third question will display only if there are 4 or more answer choices. The reason why there will be three different versions is because the wording of the question itself will be different depending on how many answer choices there are, even though all three questions are pulling answer choices from the same matrices.

However, the only option that it gives me is Selected Count, not the count of the choices themselves without being selected.

 


Forum|alt.badge.img+16

 

DP24 wrote:

 

However, the only option that it gives me is Selected Count, not the count of the choices themselves without being selected.

 

Perhaps you may wish to try

  1. separating the questions from current block into various blocks
  2. create embedded data for each matrix that has the value “count of those scale point 5” in survey flow.
  3. use math operators to sum the 3 embedded data
  4. use 3 branch logics that checks if embedded data for all 3 matrix is “1”, “2 or 3”, “4”. 
  5. set the questions into the individual branches.

vgayraud
QPN Level 5 ●●●●●
Forum|alt.badge.img+48
  • QPN Level 5 ●●●●●
  • 361 replies
  • January 15, 2025

One way I see to get your count number would be to set up a scoring category for your 3 matrices where all scores from 1 to 4 are worth 0 and all scores of 5 are worth 1.

You can then use that score in display or branch logic.

Instead of creating 3 different follow-up questions, I’d probably create a dynamic question label embedded data field in the survey flow, based on the score and pipe in that ED field value in an unique follow up question. It’s always easier to analyse data after when identical questions are stored in the same variable.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5921 replies
  • Answer
  • January 15, 2025

@DP24,

I would take a completely different approach: one question in which you use JS to change the question text based on how many rows are displayed.  It simplifies everything. 

Your question text would be something like:

<div class="qt qt1">Question text for one row</div>
<div class="qt qt23">Question text for two or three rows</div>
<div class="qt qt4">Question text for four rows</div>

JavaScript would be something like this (would be different for Simple layout):

Qualtrics.SurveyEngine.addOnload(function() {
	var q = jQuery(this.questionContainer);
	q.find(".qt").hide();
	var rows = q.find(".ChoiceRow").length;
	if(rows<2) q.find(".qt1").show();
	else if(rows<4) q.find(".qt23").show();
	else q.find(".qt4").show();
});

If your follow-up is a multiple choice instead of a matrix, just replace .ChoiceRow with .Selection.


Leave a Reply