How can I display the overall mean and mode/frequency for each multiple choice question in a survey? | XM Community
Question

How can I display the overall mean and mode/frequency for each multiple choice question in a survey?

  • 24 October 2019
  • 2 replies
  • 172 views

I am creating a multiple choice survey for respondents. I already have several responses. I am wanting to display the mean and mode (of all responses for a particular question) to respondents during the survey after each multiple choice questions. So, for example, after answering question one, I would like to be able to provide respondents with immediate feedback about the average response for that multiple choice question. I understand how to recode multiple choice questions in qualtrics and how to score each multiple choice question separately in the scoring option. I am just not sure how to display overall data to respondents and whether it requires coding each repsponse or scoring each response. I also understand how to use piped text to display a score for a question to each respondent after they have answered but this only provides THEIR score rather than the mean and frequency of all respondents responding to that particular question.

2 replies

Userlevel 5
Badge +15
Hi @saraht I hope someone is able to provide you with a more elegant solution. You could put each question in a separate survey, and set the surveys up to automatically display the results at the end, per this help page. Then, you can provide a link at the bottom of each report to go to the next question, which will really just be directing them to the next survey.
Userlevel 4
Badge +3
@saraht If you don't have too many choices/values to work with, you could use quotas + a little bit of Javascript:

Set quotas to increment for each choice/value for your question. Set their action to do nothing (only increment):
!

Quotas Counts can be piped in, which we'll use later for the math:
!

Capture the current respondent's answer in Embedded Data between two blocks (one holds the question, the next reveals the average)
!

Put something like this in the HTML editor for the question, replacing a) the quota fields ```${qo://QO...}``` with relevant ones from your survey b) the message you want c) appropriate formulas based on the quota counts and answer choice values. It'll do the math when the page loads and populate `<span id='mean'></span>`.

You'll probably want logic to exclude this calculation/show a different message for the first few respondents to give the quotas time to fill up.

```html
here's the mean: <span id="mean"></span>

<script>
var ones = parseInt("${qo://QO_1/QuotaCount}")
var twos = parseInt("${qo://QO_2/QuotaCount}")
var threes = parseInt("${qo://QO_3/QuotaCount}")
var currentAnswer = parseInt("${e://Field/thisPersonsAnswer}")
//console.log(ones, twos, threes, currentAnswer)

var mnum = ((ones*1) + (twos*2) + (threes*3) + currentAnswer)
var mden = ones+twos+threes+1
var mean = mnum/mden
//console.log(mean, mnum, mden)

document.getElementById("mean").innerHTML = mean;
</script>
```
Result:
!

Leave a Reply