Welcome to the LimeSurvey Community Forum

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

Not working question validation equation (sum) in numeric array

  • external_eval
  • external_eval's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 2 weeks ago #253227 by external_eval
Your LimeSurvey version: LimeSurvey Community Edition V. 3.28.3
Own server or LimeSurvey hosting: Our own server
Survey theme/template: Our own template (based on Fruity)
==================
Hello everyone,
I have a survey in which there is a numeric array (Q6) with subquestions filtered according to the previous multiple-choice question (Q5).
The sum of each subquestion/row in Q6 should be greater than zero (because they selected these non-zero options in Q5), yet it should also allow leaving some fields blank (because filling in many 0s would be tiring). 

The Q6 is not mandatory (to allow leaving blank fields), but I needed at least one non-zero response in at least one column in each row, so I made it kinda mandatory via the question validation equation. The equation states that the sum must be greater than zero in each row. 
I tried sum(self.sq_001.NAOK) !=0 ANDsum(self.sq_002.NAOK) !=0 ANDsum(self.sq_003.NAOK) !=0 ANDsum(self.sq_004.NAOK) !=0 AND
etc
I tried other variants, but none worked. It seems like the filtered-out subquestions fail the validation equation despite NAOK.
A sample of the survey is attached. 
Thank you!
Jakub

 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 2 weeks ago - 4 months 2 weeks ago #253228 by tpartner
You can add a condition that the corresponding row in Q5 is not empty:

Code:
(is_empty(Q5_SQ001.NAOK) OR sum(self.sq_001.NAOK) > 0) AND
(is_empty(Q5_SQ002.NAOK) OR sum(self.sq_002.NAOK) > 0) AND
(is_empty(Q5_SQ003.NAOK) OR sum(self.sq_003.NAOK) > 0) AND
(is_empty(Q5_SQ004.NAOK) OR sum(self.sq_004.NAOK) > 0) AND...

Sample survey attached: 

File Attachment:

File Name: limesurvey...6614.lss
File Size:60 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 months 2 weeks ago by tpartner.

Please Log in to join the conversation.

  • external_eval
  • external_eval's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 2 weeks ago #253231 by external_eval
Tony, thank you very much! And I noticed you simplified the relevance equation as well. Every day is a school day:)
Cheers!
Jakub

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose