- Posts: 12
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
4 months 2 weeks ago #253227
by external_eval
Not working question validation equation (sum) in numeric array was created 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
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
Attachments:
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 months 2 weeks ago - 4 months 2 weeks ago #253228
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 Not working question validation equation (sum) in numeric array
You can add a condition that the corresponding row in Q5 is not empty:
Sample survey attached:
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:
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
4 months 2 weeks ago #253231
by external_eval
Replied by external_eval on topic Not working question validation equation (sum) in numeric array
Tony, thank you very much! And I noticed you simplified the relevance equation as well. Every day is a school day:)
Cheers!
Jakub
Cheers!
Jakub
Please Log in to join the conversation.