Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Average Results with N/A answers using expressions and assesments

  • maxHal
  • maxHal's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 4 months ago - 6 years 4 months ago #161310 by maxHal
Hi! I have had a good luck around and found a few threads that begin to explore this. But nothing that seems clear to my beginners level of knowledge. I hope readers will forgive my newbie ignorance.

I have a number of groups of questions (varying number of questions per group) but all questions are 'List with Comment' type (drop down presentation).



All questions have the same answers (1-5) and I have assigned assessment values to them.

A1 100 Gold
A2 66 Silver
A3 33 Bronze
A4 0 Fail
A5 0 N/A

For each group I have added an expression. And I can average the group, no problem. If I hard code the number group questions.

Where there are 4 questions in the group...
Code:
{sum(q1.value,q2.value,q3.value,q4.value) / 4}

(which gives me a percentage)

But obviously this doesn't give a correct average if a user selects answer 5 for 1 or more questions.

I know I need to return the number of group questions (count?) but I am unsure how to do this :) How do I achieve this?

Thanks.

Max
Last edit: 6 years 4 months ago by maxHal.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #161319 by tpartner
Try this:

Code:
{sum(q1.value,q2.value,q3.value,q4.value) / sum(if (q1 == 'A5', 0, 1), if (q2 == 'A5', 0, 1), if (q3 == 'A5', 0, 1), if (q4 == 'A5', 0, 1))}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: maxHal
The topic has been locked.
  • maxHal
  • maxHal's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 4 months ago #161322 by maxHal
Thanks! The 'if's' worked out perfectly. :)
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose