Welcome to the LimeSurvey Community Forum

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

Conditional Question Group - Answers not Saving

  • mbraun
  • mbraun's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 4 months ago #220549 by mbraun
Hi everyone,

I am relatively new to limesurvey and got stuck on something. I tried checking the handbook and the forum but was unable to find what I was looking for..

I am currently making a survey which some conditionalities and I used the relevance equation for this. I have an entire question group that should only be shown under the following condition

(var1.NAOK== "A1")
and (var2.NAOK == "A1")
and (((var3a * var3b.NAOK * 8) + (var4a * var4b.NAOK * 4) + (var5a * var5b.NAOK * 3.3)) <= 600)

var1 and var2 are List(radio) and var3a - var5b are numericals, with the b's being conditional on the a's (e.g. 3b is only shown if 3a != 0, same for the others).

I used this for this question group as well as some later questions and it seemed to work perfectly in the preview ( = the questions appeared when they were supposed to appear). However, when looking at my question group, it doesn't display the entire relevance equation (only until var5b.NAOK * 3.3))  and marks the first bracket claiming it is missing a closing parentheses. This error message does not appear on the individual questions that I used this relevance equation on, only when I'm using it for a question group.

Today I activated my survey for the first time and quickly noticed that the results of the entire question group do not get saved at all. I assume it was something to do with the relevance equation (results do get saved when I set it to 1) but am unsure how to proceed now.

Kind regards,
Maya
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #220551 by holch
In cases as specific as yours it is always good to include a LSS file with only the relevant part of your survey, so we can can have a look at it.

Also, always mention the version of Limesurvey that you are using.

And with a formula like this

(((var3a * var3b.NAOK * 8) + (var4a * var4b.NAOK * 4) + (var5a * var5b.NAOK * 3.3)) <= 600)


I would always create a step in between to test. Create a equation question where you calculate that value ((var3a * var3b.NAOK * 8) + (var4a * var4b.NAOK * 4) + (var5a * var5b.NAOK * 3.3)) and you can see if the value is calculated correctly. Later you just check if the value saved in this equation question is equal or smaller than 600. When you do it in smaller steps, it is easier to check for errors.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The following user(s) said Thank You: mbraun
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #220554 by tpartner
Be careful using the plus operator, ExpressionScript may see that as a text string.

This is safer:

Code:
(sum(var3a.NAOK * var3b.NAOK * 8, var4a.NAOK * var4b.NAOK * 4, var5a.NAOK * var5b.NAOK) * 3.3 <= 600)

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: holch, mbraun
The topic has been locked.
  • mbraun
  • mbraun's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 4 months ago #220566 by mbraun
Thanks to both of you. I tried both of your advice. My survey is in attachment. The relevant parts are the IPAQ questions and the "Over u" question group. I tried saving the results in "IPAQResultaat" using sum as suggested, and the conditionalities once again seem to work. However, the issue with saving remains the same. I also noticed that IPAQResultaat does not save as a number but as NAN.

The relevance equation also still gets displayed weirdly in the group summary, leaving the last parts out and then complaining about a missing bracket

( var == "A1") && ( var == "A1") && ( result
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #220576 by Joffm
Hi, Maya,
are you sure you sent the correct survey?
In this sent survey there is only one question, one to limit the number of answers per row in an array/(numbers).

Furthermore this sent survey was created in a Limesurvey version ... what 1.92?

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • mbraun
  • mbraun's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 4 months ago #220578 by mbraun
Let's try that again! Sorry for this and thank you everyone for your patience and help!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #220581 by Joffm
Hi, Maya,

The relevance equation also still gets displayed weirdly in the group summary, leaving the last parts out and then complaining about a missing bracket

The condition worked but the logic file complaind.
In my opinion it is because of the "<=". The editor might see it as the start of a tag (like <span>).
Change to
OfAge.NAOK == "A1" && Gezondheid.NAOK == "A1" && IPAQResultaat.NAOK le 600

And I see no issue in saving the Resultaat
 

What you can try is to set the equation into the question text, not in this "equation field"
 
You see I removed some obsolete brackets.


If there are errors you will see it better.

 

File Attachment:

File Name: limesurvey... (1).lss
File Size:58 KB


One last word.
Do you really think to show the survey like this?
All on one page and with numeric entry fields of full length?
 

Tot ziens
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: mbraun
The topic has been locked.
  • mbraun
  • mbraun's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 4 months ago #220586 by mbraun
Hi Joffm,

Thank you for your work and time! I really appreciate it and you really helped me so much already.

I imported your survey and the result still is displayed as NAN as soon as one or more zeros are put in, unfortunately. We expect most users to put in a zero for at least one of the questions, so that's a bit of a pity. I assume this is the case because the other question (IPAQ2, 4 or 6) do not get posed if their equivalent is 0? But haven't found a way to get around this. However, this is not really an issue for us as long as the conditions still work normally since we can easily calculate it ourselves afterwards.

The other values do seem to get saved, but only if I keep the question IPAQ Resultaat unhidden. I now moved the equation back to the equation field and put some generic text as question in order to make it look ok for participants. I'm ok with this solution I think, but there must be a more elegant way? I thought the entire idea of the equation function was that it could remain hidden to be honest..

About your last comment: I didn't occupy myself with the aesthetics of it much (yet) ;) But it will probably stay on one page
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago - 3 years 4 months ago #220599 by Joffm
Sorry, I did not check the answer table, after I got the correct result in the equation.

Well, so we just have to check it.
If IFAQ1>0 then add the multiplication, otherwise add 0.
So change the equation to
{sum(if(IPAQ1>0,IPAQ1.NAOK * IPAQ2.NAOK * 8,0),if(IPAQ3>0,IPAQ3.NAOK * IPAQ4.NAOK * 4,0),if(IPAQ5>0,IPAQ5.NAOK * IPAQ6.NAOK * 3.3,0))}

Here the answer table with the NANs, but in the last row there is the result though there is a "0" in IFAQ5
 

Joffm

And as you say: equations usually are hidden - and the work always.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 4 months ago by Joffm.
The following user(s) said Thank You: mbraun
The topic has been locked.
  • mbraun
  • mbraun's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 4 months ago #220645 by mbraun
I cannot thank you enough! Really appreciate the help. It works perfectly
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose