- Posts: 162
- Thank you received: 14
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Computer number of non-N/A responses.
- teracomp
- Topic Author
- Offline
- Elite Member
Less
More
3 months 3 weeks ago #254095
by teracomp
Dave Phillips
Computer number of non-N/A responses. was created by teracomp
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition Version 6.4.0+231218
Own server or LimeSurvey hosting: Own Server
Survey theme/template: Custom theme based on Bootswatch
==================
I have a number of computations within a survey that look like:
round(sum( HM1.value + HM2.value + HM3.value + HM4.value + HM5.value + HM6.value + HM7.value + HM8.value ) / 8, 2)
However, each of the questions (HM1...HM8) includes an answer option of N/A. The value for N/A = 0. The denominator needs to be a variable based on the number of non-zero responses. For example, if HM1.value == 0 and all of the other questions are non-zero, the denominator would be 7 (not .
I need to do this for ten (10) subscales that have 4 to 8 questions each.
Is is possible to create a variable for the denominator in the equation?
Many thanks!
dave
Your LimeSurvey version: LimeSurvey Community Edition Version 6.4.0+231218
Own server or LimeSurvey hosting: Own Server
Survey theme/template: Custom theme based on Bootswatch
==================
I have a number of computations within a survey that look like:
round(sum( HM1.value + HM2.value + HM3.value + HM4.value + HM5.value + HM6.value + HM7.value + HM8.value ) / 8, 2)
However, each of the questions (HM1...HM8) includes an answer option of N/A. The value for N/A = 0. The denominator needs to be a variable based on the number of non-zero responses. For example, if HM1.value == 0 and all of the other questions are non-zero, the denominator would be 7 (not .
I need to do this for ten (10) subscales that have 4 to 8 questions each.
Is is possible to create a variable for the denominator in the equation?
Many thanks!
dave
Dave Phillips
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
3 months 3 weeks ago #254096
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Computer number of non-N/A responses.
You can use
{countif("0",HM1.value, HM2.value,...)} to get the number of N/A,
or
{countifop(">","0",HM1.value,...)}
to get the number of "not N/A".
So at the end you will have somthing like
{round(sum(....) / countifop(...),2)}
Joffm
{countif("0",HM1.value, HM2.value,...)} to get the number of N/A,
or
{countifop(">","0",HM1.value,...)}
to get the number of "not N/A".
So at the end you will have somthing like
{round(sum(....) / countifop(...),2)}
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: teracomp
Please Log in to join the conversation.
- teracomp
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 162
- Thank you received: 14
3 months 3 weeks ago #254097
by teracomp
Dave Phillips
Replied by teracomp on topic Computer number of non-N/A responses.
Fantastic! Here's what I have for this question:
round(sum(HM1.value + HM2.value + HM3.value + HM4.value + HM5.value + HM6.value + HM7.value + HM8.value) / countifop(">", "0", HM1.value, HM2.value, HM3.value, HM4.value, HM5.value, HM6.value, HM7.value, HM8.value), 2)
I'll test to confirm.
round(sum(HM1.value + HM2.value + HM3.value + HM4.value + HM5.value + HM6.value + HM7.value + HM8.value) / countifop(">", "0", HM1.value, HM2.value, HM3.value, HM4.value, HM5.value, HM6.value, HM7.value, HM8.value), 2)
I'll test to confirm.
Dave Phillips
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
3 months 3 weeks ago #254098
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Computer number of non-N/A responses.
I hope it was a typo.
It's sum(a,b,c,..)
not sum(a+b+c+...)
Joffm
It's sum(a,b,c,..)
not sum(a+b+c+...)
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: teracomp
Please Log in to join the conversation.
- teracomp
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 162
- Thank you received: 14
3 months 3 weeks ago #254099
by teracomp
Dave Phillips
Replied by teracomp on topic Computer number of non-N/A responses.
Yikes! I've been using sum(a+b+c+...) forever!
Dave Phillips
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
3 months 3 weeks ago #254100
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Computer number of non-N/A responses.
And you know what you were doing?
First you do an addition
"a+b+c" with a result "d".
Then you use the sum-function to "sum(d)".
So one part is obsolet.
Joffm
First you do an addition
"a+b+c" with a result "d".
Then you use the sum-function to "sum(d)".
So one part is obsolet.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: teracomp
Please Log in to join the conversation.
- teracomp
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 162
- Thank you received: 14
3 months 3 weeks ago #254101
by teracomp
Dave Phillips
Replied by teracomp on topic Computer number of non-N/A responses.
round(sum(HM1.value, HM2.value, HM3.value, HM4.value, HM5.value, HM6.value, HM7.value, HM8.value, HP1.value, HP2.value, HP3.value, HP4.value, HP5.value, HP6.value, HP7.value, HP8.value) / countifop(">", "0", HM1.value, HM2.value, HM3.value, HM4.value, HM5.value, HM6.value, HM7.value, HM8.value, HP1.value, HP2.value, HP3.value, HP4.value, HP5.value, HP6.value, HP7.value, HP8.value), 2)
Works perfectly! Thank you!
Works perfectly! Thank you!
Dave Phillips
Please Log in to join the conversation.