Pipe in highest value from a side-by-side question | XM Community
Skip to main content

Pipe in highest value from a side-by-side question

  • July 21, 2022
  • 10 replies
  • 93 views

Forum|alt.badge.img+6

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.
side by side.JPG

10 replies

Forum|alt.badge.img+6
  • Author
  • QPN Level 2 ●●
  • 27 replies
  • July 22, 2022

TomG PeeyushBansal Could you please have a look


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6083 replies
  • July 22, 2022

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);
});


Forum|alt.badge.img+6
  • Author
  • QPN Level 2 ●●
  • 27 replies
  • July 22, 2022

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.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6083 replies
  • July 22, 2022

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.value
with
this.options[this.selectedIndex].text


Forum|alt.badge.img+6
  • Author
  • QPN Level 2 ●●
  • 27 replies
  • July 22, 2022

Awesome. It is working fine now TomG. thank you so much.
I have a few doubts:

  1. Would this embedded field 'highest' be available in the excel file when exported?

  2. 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)
  1. 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).


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6083 replies
  • July 22, 2022

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.


Forum|alt.badge.img+6
  • Author
  • QPN Level 2 ●●
  • 27 replies
  • July 22, 2022

Thank you TomG for explaining everything


Forum|alt.badge.img+6
  • Author
  • QPN Level 2 ●●
  • 27 replies
  • June 21, 2023

@TomG Hi Tom. Could you please help on this? For a matrix type question how to create embedded data based on the Max score selected from the responses in A, B, C and D.

And if this is a loop and merge question where this question there would be shown 10 times would 10 embedded data be created?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6083 replies
  • June 21, 2023

@TomG Hi Tom. Could you please help on this? For a matrix type question how to create embedded data based on the Max score selected from the responses in A, B, C and D.

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.


Forum|alt.badge.img+6
  • Author
  • QPN Level 2 ●●
  • 27 replies
  • June 21, 2023

Thank you so much Tom