Math operation for calculating the maximum value | XM Community
Solved

Math operation for calculating the maximum value

  • 1 March 2019
  • 5 replies
  • 278 views

Badge +1
I have three questions that ask about respondents' travel distance.

And I want to redirect a respondent at the end of a survey to different URLs, based on the longest distance reported, like:
* If the longest distance among three is less than 5: redirect to "google.com"
* If the longest distance among three is between 5 and 10: redirect to "youtube.com"
* If the longest distance among three is over than 10: redirect to "amazon.com"

So, for example, if a respondent answered 5, 3, 8 miles for each question, I'd like to redirect this respondent to "youtube.com" because the longest one is "8."

Is it possible to do this by using math operations or javascript?

I tried to use Qualtrics' math operation, but it seems that there is no operation for like this: $e{max(q://QID16ChoiceTextEntryValue, q://QID17ChoiceTextEntryValue, q://QID18ChoiceTextEntryValue)}

Any suggestions will be welcome.

Thank you.
icon

Best answer by TomG 1 March 2019, 16:38

View original

5 replies

Userlevel 7
Badge +33
you can use simple if conditions or java script to punch max value from 3 numbers.
Hello @jhwang ,

You can use Redirect to URL option to redirect the respondent
Badge +1
Hello @Shashi ,
I know how to use Redirect to URL option. But I want to know how to detect the maximum value of reported answers and then redirect the respondent based on the value.
Userlevel 7
Badge +27
JS:
```
var max = Math.max(parseInt("${q://QID16ChoiceTextEntryValue"), parseInt("${q://QID17ChoiceTextEntryValue}"), parseInt("${q://QID18ChoiceTextEntryValue)}"));
Qualtrics.SurveyEngine.setEmbeddedData("max", max);
```
In survey flow branch: If max > X etc.
Badge +1
Thank you very much, @TomG!

This is what I exactly wanted to do.

Leave a Reply