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
3 weeks 6 days 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
3 weeks 6 days 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.

More
3 weeks 3 days ago #272555 by altman.geo
Joffm,

Thank you so much for this very detailed and informative reply! I greatly appreciate your tip on using array (numbers) instead of array (text) and made this switch. And I think your equation/tip coding solutions will accomplish what I need when I put all the coding/equations in the right place ... but I am still a bit unclear on just how to do that. Please accept my apologies: While I am experienced building surveys, I'm completely new to the LimeSurvey platform and am still learning how to properly set things up here. If you can help me out with the handful of follow-up questions below, I should hopefully have everything I need moving forward:

1. What is the process to code subquestions within array (numbers) questions so the Y-axis is coded Y1, Y2, Y3, etc., and the X-axis is X1, X2, X3, etc.? I do not understand where/how to set this up?

2. Where should I be putting the validation equation for it to work properly? I see 3 few potential options: (1) question settings > advanced > logic > question validation equation, (2) question settings > advanced > logic > subquestion validation equation, (3) question settings > advanced > general > input validation

3. Where should I be putting the validation tip coding for it to work properly and only appear when a response violates the numeric comparison conditions? I see 2 potential options here: (1) question settings > advanced > logic > question validation tip, (2) question settings > advanced > logic > subquestion validation tip

4. Yes, you are 100% correct: It would be better to have the validation tip point exactly to the cells creating the error (or errors, as there could be more than  one problem) instead of giving a general error message. I wouldn't ask you to write a tip equation/code that does this one-by-one for ALL potential errors laid out in my previous example, but could you help me with a tip equation/code that does this for, say, the first 3 error types (Y2_X1>Y1_X1, Y3_X1>Y1_X1, Y4_X1>Y1_X1), so I can see how to structure the tip coding to have different specific tip messages for different errors? 

If you can help me get on track with the 4 items above, that will give me a working template that I can apply throughout my survey, and I should hopefully be in good shape and need no further assistance. Thanks again for the help!

Best,
George

Please Log in to join the conversation.

More
3 weeks 3 days ago - 3 weeks 3 days ago #272556 by Joffm
HI,

I do not understand where/how to set this up?

 

Where should I be putting the validation equation

you wrote it, "question validation equation"
NOT "subquestion validation equation" and not "Input validation" (as you see here, you only enter a regular expression")

The same for the tip.

Anyway, you should read the manual about this and import and srudy the sample surveys.

how to structure the tip coding to have different specific tip messages for different errors? 

Here you use a nested IF, like
{if(Q1_Y1_X1<max(Q1_Y2_X1.NAOK,Q1_Y3_X1.NAOK,Q1_Y4_X1.NAOK),'Total can't be less then the parts in column 1', if(Q1_Y1_X3<max(Q1_Y2_X3.NAOK,Q1_Y3_X3.NAOK,Q1_Y4_X3.NAOK),'Total can't be less then the parts in column 3, if(....),'message3, if(....),'message3,''))))}

Here you have to decide what exactly you want to check and display.

If there are further questions create a small sample and send the lss export.

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 weeks 3 days ago by Joffm.

Please Log in to join the conversation.

More
3 weeks 3 days ago #272558 by altman.geo
Joffm,

Thank you again -- so much! -- for the fast and helpful response! Based on the information you provided, I think that I'm clear on where to put the validation equation coding and validation tip coding, as well as how to construct the validation tip with a nested IF so I can create error messages that highlight exactly what is wrong with the particular response, instead of giving a general error message. But there's one last thing here, which I think is pretty simple, I'm still having trouble with: I can't figure out where on the LimeSurvey platform I can find the screen that you screenshotted, where the subquestion codes can be edited. When I went under survey structure, I saw how to show/hide question codes and did so, but even after doing this, I can see the subquestion codes but I am not able to select or edit them, and the screen looks different from your image, so I think I must be in the wrong place. Here is a screenshot so you can see where I am and what is happening:

 

How would I navigate to the page with the editable subquestion codes that you screenshotted? Thank you in advance -- I am so grateful for the help!!!

Best,
George

Please Log in to join the conversation.

More
3 weeks 2 days ago #272577 by Joffm
As you use the "new" editor, I can't help.
In my opinion there are some features still missing.

Better you use the "classic" editor.

Joffm

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

Please Log in to join the conversation.

More
3 weeks 1 day ago #272586 by altman.geo
I see -- that makes sense! I will make sure to use the Classic editor moving forward. I now have everything I need to move forward on my project at this point. Thank you so, so much for all of your help! I thoroughly tested the solutions that you put together for me, and they work exactly as needed. I greatly appreciate your time and expertise!

Best,
George

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose