Welcome to the LimeSurvey Community Forum

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

Question validation equation

  • jackuars
  • jackuars's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 7 months ago - 6 years 7 months ago #157425 by jackuars
Question validation equation was created by jackuars
Hi please take a look at the question group I created.

It has 4 questions

1. How much do you pay for your internet now? [ListRadio with 4 options "100-150, 151-200, 201-250, 251-300"]
2. What is the exact amount you pay for your internet? [Numeric, The number you input here should be based on Question 1 within the same range]
3. Has the amount increased/decreased compared to last time [ListRadio with 2 options "Increase" & "Decrease"]
4. How much did you pay for your internet earlier [Numeric, the answer should satisfy the condition based on Q2 and Q3]

But somehow it doesn't work when you choose option 2, 3 or 4 in Question 1 with a message "not answered in a valid manner". Can you please tell me how to correct this? I would prefer if no more question is to be added.
Last edit: 6 years 7 months ago by jackuars.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 7 months ago #157460 by Joffm
Replied by Joffm on topic Question validation equation
Hi,

comparison is "Q1==1", NOT "Q1=1".

I will check more intensively later.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • jackuars
  • jackuars's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 7 months ago #157461 by jackuars
Replied by jackuars on topic Question validation equation
I tried that too, but it gives me same popup error
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 7 months ago #157465 by Joffm
Replied by Joffm on topic Question validation equation
Hi, jackuars,
well, that's because there was something wrong in your equation.

I tried a different approach:
You have the four categories in Q2: 1,2,3,4 and the ranges : "101-150", "151-200", ...
So you can calculate the ranges by (Q2+1)*50+1 - (Q2+2)*50.

Therefore I changed your validation equation to :
((Q2.NAOK+1)*50<Q2a.NAOK) AND (Q2a.NAOK<=(Q2.NAOK+2)*50)

Your second equation in Q2c is fine.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 7 months ago #157477 by Joffm
Replied by Joffm on topic Question validation equation
Hi,
just to add something.

When we ask for age or other real numbers and need the classification too, we ask only the number and calculate the category by a hidden equation.
Is there a special reason that you do it the other way?

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: jackuars
The topic has been locked.
  • jackuars
  • jackuars's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 7 months ago - 6 years 7 months ago #157562 by jackuars
Replied by jackuars on topic Question validation equation
Thank you for your alternate expression, I will try it out.

The survey is conducted in this way because we needed to know that the respondents are not giving rigged answers, so that if it does validate as per their previous question, then most certainly we can know that they're not doing it in a hurry.

But most of all, what I wanted to know is that what's wrong with my question validation equation for Q2a.

If you just consider the first 2 questions (Q2 & Q2a), the first question asks 4 options, and the second question simply has a validation for a numerical input to see if it falls inside the range of the previous question.
Last edit: 6 years 7 months ago by jackuars.
The topic has been locked.
  • jackuars
  • jackuars's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 7 months ago #157563 by jackuars
Replied by jackuars on topic Question validation equation
Hi, I found what was wrong with the equation.

Else-if statements requires a else statement at the end, and should never end with elseif.

Previously the equation read as:
if(Q2=="1",Q2a>=101 and Q2a<=150,
if(Q2=="2",Q2a>=151 and Q2a<=200,
if(Q2=="3",Q2a>=201 and Q2a<=250,
if(Q2=="4",Q2a>=251 and Q2a<=300))))

I changed it to:
if(Q2=="1",Q2a>=101 and Q2a<=150,
if(Q2=="2",Q2a>=151 and Q2a<=200,
if(Q2=="3",Q2a>=201 and Q2a<=250,
Q2a>=251 and Q2a<=300)))

The only change is coming in the last part of the equation.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose