Welcome to the LimeSurvey Community Forum

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

Validating by comparing numerical responses in an array (texts) question

More
10 hours 55 minutes ago #272548 by altman.geo
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
(Write here your question/remark)Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Cloud Version 6.15.11
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: N/A
==================
Hello, I need help putting together a survey response validation equation for use in LimeSurvey. I've laid out the details below. If you can help with this -- or know someone who can -- please either respond to this post or email me directly (george@vettedemployers.com).

I need this validation for an array question collecting numerical text responses. I will need the validation equation to require responses to be numbers and then to compare those numbers to other data entered in the same question, returning an error message if certain numbers are larger than other numbers. Please refer to the screenshot below.

 

I need to do multiple validations for this question, which has question code Q001 in my survey (the subquestion codes should be the default for array question columns/rows). This validation should do 3 things:

1. Make all the vertical comparisons (blue arrows), ensuring that the cell with the arrow point is always greater than or equal to the cell that the arrow started in (so total employees >= veterans, total employees >= Guard/Reserve, etc)

2. Make all the horizontal comparisons (orange arrows), ensuring that the cell with the arrow point is always greater than or equal to the cell that the arrow started in (so new hire total >= new hires remaining)

3. Ensure that the validation does not fail because part of the response was left blank (we want them to be able to continue through the survey even if they don't have the data)

If you can respond with a validation equation that accomplishes this, I would be very grateful. If it would be better to communicate with me directly first, please feel free to reach out at george@vettedemployers.com. Thank you!

Best,
George

Please Log in to join the conversation.

More
5 hours 52 minutes ago #272550 by Joffm
Hi,
first you should use an array(numbers) -> no need to check for numerical input.

Now, if you code your y-axis "Y1", "Y2", "Y3" and "Y4" and the x-axis "X1", "X2", "X3" and "X4" you have to consider that you only can compare if both fields are filled.
I do not recommend the default coding because of the danger to get confused "what is coulumn, what is row?"

Then it is rather straightforward.
For each of your comparisons you say:
the first is empty or the second is empty or the second is less or equal the first.
This ai a logical term, that is TRUE if one of the three parts is TRUE.

(is_empty(Q1_Y1_X1) or is_empty(Q1_Y2_X1) or Q1_Y2_X1.NAOK le Q1_Y1_X1.NAOK) and
(is_empty(Q1_Y1_X1) or is_empty(Q1_Y3_X1) or Q1_Y3_X1.NAOK le Q1_Y1_X1.NAOK) and
(is_empty(Q1_Y1_X1) or is_empty(Q1_Y4_X1) or Q1_Y4_X1.NAOK le Q1_Y1_X1.NAOK) and
(is_empty(Q1_Y1_X3) or is_empty(Q1_Y2_X3) or Q1_Y2_X3.NAOK le Q1_Y1_X3.NAOK) and
(is_empty(Q1_Y1_X3) or is_empty(Q1_Y3_X3) or Q1_Y3_X3.NAOK le Q1_Y1_X3.NAOK) and
(is_empty(Q1_Y1_X3) or is_empty(Q1_Y4_X3) or Q1_Y4_X3.NAOK le Q1_Y1_X3.NAOK) and
(is_empty(Q1_Y1_X1) or is_empty(Q1_Y1_X2) or Q1_Y1_X2.NAOK le Q1_Y1_X1.NAOK) and
(is_empty(Q1_Y2_X1) or is_empty(Q1_Y2_X2) or Q1_Y2_X2.NAOK le Q1_Y2_X1.NAOK) and
(is_empty(Q1_Y3_X1) or is_empty(Q1_Y3_X2) or Q1_Y3_X2.NAOK le Q1_Y3_X1.NAOK) and
(is_empty(Q1_Y4_X1) or is_empty(Q1_Y4_X2) or Q1_Y4_X2.NAOK le Q1_Y4_X1.NAOK) and
(is_empty(Q1_Y1_X3) or is_empty(Q1_Y1_X4) or Q1_Y1_X4.NAOK le Q1_Y1_X3.NAOK) and
(is_empty(Q1_Y2_X3) or is_empty(Q1_Y2_X4) or Q1_Y2_X4.NAOK le Q1_Y2_X3.NAOK) and
(is_empty(Q1_Y3_X3) or is_empty(Q1_Y3_X4) or Q1_Y3_X4.NAOK le Q1_Y3_X3.NAOK) and
(is_empty(Q1_Y4_X3) or is_empty(Q1_Y4_X4) or Q1_Y4_X4.NAOK le Q1_Y4_X3.NAOK)


And for the validation tip you can do it the easy way. Only show an error message if there is an error somewhere
{if((is_empty(Q1_Y1_X1) or is_empty(Q1_Y2_X1) or Q1_Y2_X1.NAOK le Q1_Y1_X1.NAOK) and
(is_empty(Q1_Y1_X1) or is_empty(Q1_Y3_X1) or Q1_Y3_X1.NAOK le Q1_Y1_X1.NAOK) and
(is_empty(Q1_Y1_X1) or is_empty(Q1_Y4_X1) or Q1_Y4_X1.NAOK le Q1_Y1_X1.NAOK) and
(is_empty(Q1_Y1_X3) or is_empty(Q1_Y2_X3) or Q1_Y2_X3.NAOK le Q1_Y1_X3.NAOK) and
(is_empty(Q1_Y1_X3) or is_empty(Q1_Y3_X3) or Q1_Y3_X3.NAOK le Q1_Y1_X3.NAOK) and
(is_empty(Q1_Y1_X3) or is_empty(Q1_Y4_X3) or Q1_Y4_X3.NAOK le Q1_Y1_X3.NAOK) and
(is_empty(Q1_Y1_X1) or is_empty(Q1_Y1_X2) or Q1_Y1_X2.NAOK le Q1_Y1_X1.NAOK) and
(is_empty(Q1_Y2_X1) or is_empty(Q1_Y2_X2) or Q1_Y2_X2.NAOK le Q1_Y2_X1.NAOK) and
(is_empty(Q1_Y3_X1) or is_empty(Q1_Y3_X2) or Q1_Y3_X2.NAOK le Q1_Y3_X1.NAOK) and
(is_empty(Q1_Y4_X1) or is_empty(Q1_Y4_X2) or Q1_Y4_X2.NAOK le Q1_Y4_X1.NAOK) and
(is_empty(Q1_Y1_X3) or is_empty(Q1_Y1_X4) or Q1_Y1_X4.NAOK le Q1_Y1_X3.NAOK) and
(is_empty(Q1_Y2_X3) or is_empty(Q1_Y2_X4) or Q1_Y2_X4.NAOK le Q1_Y2_X3.NAOK) and
(is_empty(Q1_Y3_X3) or is_empty(Q1_Y3_X4) or Q1_Y3_X4.NAOK le Q1_Y3_X3.NAOK) and
(is_empty(Q1_Y4_X3) or is_empty(Q1_Y4_X4) or Q1_Y4_X4.NAOK le Q1_Y4_X3.NAOK),'','There is an error')}





Of course you can refine this to point exactly to the cell doing it one by one with e specific message.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose