- Posts: 5
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Sumifop issue
- stinem1
- Topic Author
- Offline
- New Member
Less
More
7 years 1 month ago #148081
by stinem1
Sumifop issue was created by stinem1
Hi all,
I'm having trouble with the "sumifop" function, similar to this old (unresolved) issue: www.limesurvey.org/forum/design-issues/94333-sumifop
In short, I want to get the sum of the scores of radio list questions, but only those scores greater than zero.
I created an equation question with the following:
{sumifop(">", 0, B1.valueNAOK, B2.valueNAOK)}
If I select the answer for B1 that gives me a score of 1000, and the answer for B2 that gives me a score of 1000, I get:
"010001000" instead of the sum of the two scores, 2000.
It appears to be correctly selecting the answers I want, but instead of adding them as values, it is joining them into a string.
If I use {sum(B1.valueNAOK, B2.valueNAOK)}, it works just fine, but obviously isn't filtering for the scores greater than zero.
Any suggestions? I'm stumped.
Thanks,
Megan
I'm having trouble with the "sumifop" function, similar to this old (unresolved) issue: www.limesurvey.org/forum/design-issues/94333-sumifop
In short, I want to get the sum of the scores of radio list questions, but only those scores greater than zero.
I created an equation question with the following:
{sumifop(">", 0, B1.valueNAOK, B2.valueNAOK)}
If I select the answer for B1 that gives me a score of 1000, and the answer for B2 that gives me a score of 1000, I get:
"010001000" instead of the sum of the two scores, 2000.
It appears to be correctly selecting the answers I want, but instead of adding them as values, it is joining them into a string.
If I use {sum(B1.valueNAOK, B2.valueNAOK)}, it works just fine, but obviously isn't filtering for the scores greater than zero.
Any suggestions? I'm stumped.
Thanks,
Megan
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
7 years 1 month ago #148083
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Sumifop issue
What if you don't use "NAOK"?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- stinem1
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
7 years 1 month ago #148085
by stinem1
Replied by stinem1 on topic Sumifop issue
Thanks for writing back!
No change.
No change.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
7 years 1 month ago #148087
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Sumifop issue
Which version of LS are you using and can you provide a .lss file that only contains the questions relevant for this problem so we can test?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- stinem1
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
7 years 1 month ago #148089
by stinem1
Replied by stinem1 on topic Sumifop issue
Version 2.57.1+161205
Attached is one group of questions from the survey, where I've been doing my testing. Eventually I need to implement it for the whole survey (>150 Qs).
Thanks so much.
Attached is one group of questions from the survey, where I've been doing my testing. Eventually I need to implement it for the whole survey (>150 Qs).
Thanks so much.
Attachments:
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
7 years 1 month ago #148092
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Sumifop issue
Not sure where sumifop comes into play with these two questions?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
7 years 1 month ago #148094
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 Sumifop issue
It's a bug - I can reproduce it in 2.6.2.
Please file a bug report - bugs.limesurvey.org/
The JavaScript is seeing the values as strings instead of numbers, so concatenating them instead of adding them.
As a workaround, try something like this:
Please file a bug report - bugs.limesurvey.org/
The JavaScript is seeing the values as strings instead of numbers, so concatenating them instead of adding them.
As a workaround, try something like this:
Code:
{sum(if(B1.value > 0, B1.value, 0), if(B2.value > 0, B2.value, 0))}
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: DenisChenu
The topic has been locked.
- stinem1
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
7 years 1 month ago #148099
by stinem1
Replied by stinem1 on topic Sumifop issue
Will do. Thanks for the confirmation and the workaround!
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
7 years 1 month ago #148109
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Sumifop issue
But please : fill a bug report , think it's linked with
github.com/LimeSurvey/LimeSurvey/commit/...c77aef09fd4c48e73b7d
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
7 years 1 month ago #148120
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 Sumifop issue
Yeah, probably. I don't know whether that's causing problems elsewhere but it seems sumifop could be be easily fixed by using Number(arg) in function LEMsumifop(). (untested)
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: DenisChenu
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
7 years 1 month ago #148121
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Sumifop issue
Yes, but still : if we need to add Number(arg) each time we use a new function ......
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
7 years 1 month ago #148122
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 Sumifop issue
Yes, I know, that's why I said it's not necessarily a global fix.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.