How to Pipe in the highest value among 4 rating scales in a side-by-side question into an embedded field.
Example:
Q#1 Rating for ques 1 = 5
Q# 2 Rating for ques 2 = 4
Q# 3 Rating for ques 2 = 5
Q# 5 Rating for ques 2 = 9
Output: I want to pull the value 9 as an embedded field.
I want to create an embedded field that pulls the highest value among these 4 columns.
TomG PeeyushBansal Could you please have a look
Try this:
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var val, highest = 0;
jQuery("#"+this.questionId+" select").each(function() {
if((val=parseInt(this.value)) > highest) highest = val;
});
Qualtrics.SurveyEngine.setEmbeddedData('highest',highest);
});
Hi TomG . Thank you for the reply. Somehow the embedded value I am getting is the actual value + 1. For example, If the highest value among 4 scales is 5, the embedded field is populating highest as 6. How to fix this.
https://community.qualtrics.com/XMcommunity/discussion/comment/47944#Comment_47944I was afraid of that. It is because you somehow edited the options so that the value (choice id) doesn't match the option text. Replace
this.valuewith
this.options[this.selectedIndex].text
Awesome. It is working fine now TomG. thank you so much.
I have a few doubts:
- Would this embedded field 'highest' be available in the excel file when exported?
- Would this field 'highest' can be used in a math operation where it would be like
New embedded value = 'highest' + embedded value 2 (rating from another question)
- Also, right now it is pulling the highest from the entire statements, right? There are like 18 statements in the side-by-side question. For getting the highest value for each statement, would I have to split the question into 18 questions or Is there another way to find the highest value for each statement that can be a new embedded value (so total of 18 embedded values).
Would this embedded field 'highest' be available in the excel file when exported?
Yes, if you define highest in the survey flow prior to the block
Would this field 'highest' can be used in a math operation where it would be like
Yes refer to it as e://Field/highest in your math operation.
Also, right now it is pulling the highest from the entire statements, right?
Correct
... or Is there another way to find the highest value for each statement that can be a new embedded value (so total of 18 embedded values).
You can add a second loop (the current loop would be nested inside it) that loops through the rows.
Thank you TomG for explaining everything
And if this is a loop and merge question where this question there would be shown 10 times would 10 embedded data be created?
And if this is a loop and merge question where this question there would be shown 10 times would 10 embedded data be created?
I have a function, matrixHiLo, that does this. For a loop, you could pipe a loop field into the function prefix option to record embedded data for each loop.
Thank you so much Tom
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.