Pull top 5 responses from constant sum | XM Community
Solved

Pull top 5 responses from constant sum

  • 19 November 2018
  • 1 reply
  • 39 views

In my current survey, I have a constant sum question with 20+ answer options. I am asking respondents to input the percentage of time (0 - 100) they spend across 20+ daily activities. I want to then ask a number of follow-up questions regarding the activities that they spend most of their time on. The current options with qualtrics allow me to carry forward answers that are greater than a certain amount from that constant sum question. Although this is a potential solution, it does not solve my problem perfectly (think of selecting 10% as my greater than amount and having individuals allocate all their time on single digit % increments, etc.).

Most of my follow-up questions will be matrix tables. Is there any way to pull forward the top 5 answers from a prior constant sum based on the inputted values from the respondent?

Thanks ahead of time for the help!
icon

Best answer by fleb 20 November 2018, 12:46

View original

1 reply

Userlevel 5
Badge +6
I hope I am correct if I suppose all your daytime activities are in one question of type Slider and that the following questions for each activity are always the same.

1) Create an array of all your responses like this:
`var timePercent = ["${q://QID16/ChoiceNumericEntryValue/1}" , "${q://QID16/ChoiceNumericEntryValue/2}", ..., "${q://QID16/ChoiceNumericEntryValue/20}"]`
(Be aware, you can"t use for loop to get this array, for more details see here)

2) Create the array of your activity names in the same order in the format you want to use in following questions. (You can do it based on this piped text` "${q://QID1/ChoiceGroup/AllChoices?displayLogic=0}"`) if the form is the same as in the original question.)

3) Get indexes of top 5 elements of the array of responses and get corresponding activity names.

4) Concatenate the array into one string and send it to an embedded field.

5) Create a new loop and merge block containing questions on activities. In JavaScript ot this Question do something like this but use the string from embedded field split to array again instead a new array.

Qualtrics.SurveyEngine.addOnload(function()
{
var x = Number("${lm://CurrentLoopNumber}")-1;
var myArray = ["A", "B", "C"];
{jQuery(this.getQuestionTextContainer()).append("Some text "+ myArray[x])}
});

P.S.: I used single quotation marks instead of double ones, but I am not able to use them at this forum from an unknown reason. The code sometimes does not work with double ones as piped text is processd first.

Leave a Reply