- Posts: 6
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
6 years 4 months ago - 6 years 4 months ago #161310
by maxHal
Average Results with N/A answers using expressions and assesments was created 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...
(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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10103
- Thank you received: 3591
6 years 4 months ago #161319
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Average Results with N/A answers using expressions and assesments
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
6 years 4 months ago #161322
by maxHal
Replied by maxHal on topic Average Results with N/A answers using expressions and assesments
Thanks! The 'if's' worked out perfectly.
The topic has been locked.