Math operation for calculating the maximum value | XM Community
Skip to main content
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.
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
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.
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.
Thank you very much, @TomG!



This is what I exactly wanted to do.

Leave a Reply