Welcome to the LimeSurvey Community Forum

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

Save a multiplication in the results. Only 0 or NAN is saved.

  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
8 years 7 months ago #123447 by jelo
Think of multiple choice question with three answers.

Then a equation question with this content:
Code:
sum(((check_SQ001.NAOK == "Y") * 5) + ((check_SQ002.NAOK == "Y") * 10) + ((check_SQ003.NAOK == "Y") * 15))

When you check all three answers the result of the equation is (1*5)+(1*10)+(1*15)=30.
This is displayed correctly but Limesurvey saves NAN in the results.

This behavior might be as intended.But how to save the result of such calculation inside the results?
LS Version 2.06+ Build 150731and Version 2.05+ Build 150508 both show the same behavior.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
8 years 7 months ago #123453 by jelo
Just a demo survey with checkbox and radiobutton question. Values from the single choice question are saved, when using multiplechoice items 0 or NAN are saved in the results. Perhaps I'm too dumb and too blind.


File Attachment:

File Name: test_equat...save.lss
File Size:17 KB

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago #123454 by tpartner
It may be because check_SQ001.NAOK == "Y" returns true or false, not a number. Try using equation questions to define those variables.

Something like this in the equation:
Code:
if (check_SQ001.NAOK == "Y", 1, 0)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
8 years 7 months ago - 8 years 7 months ago #123455 by jelo
Thanks for your time.
When you run the survey the values are all calculated fine. It is the saving in the results which won't work.

I have tried different things over 4 hours to find where I made a mistake. But every workaround (e.g. using count or if ) I could think of didn't changed the missing value in the results.

And Limesurvey itself is creating this relevance equation from the condition "checkbox 1 is ticked":
((check_1.NAOK == "Y"))

What a riddle.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Last edit: 8 years 7 months ago by jelo.
The topic has been locked.
  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
8 years 7 months ago #123460 by jelo
Mhm. Tony. I tried it once again with the IF. This time it worked. I still wonder, why the value is shown correctly, but not saved. Thanks again for motivating me to try it once again with the IF concept.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago - 8 years 7 months ago #123466 by tpartner
That might be worthy of a bug report.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 7 months ago by tpartner.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose