Condition from result of an equation

More
1 month 2 weeks ago #199687 by arnaudbore
Dear experts,

I would like to know if there a way to create a condition from the result of an equation question.

I have a equation question that gives me the age of a participant.
I would like the next question to appear if age between 12 and 49.

So far, condition editor put an OR instead of a AND...

Thank you for your help
Arnaud

Please Log in to join the conversation.

LimeSurvey Partners
More
1 month 2 weeks ago #199690 by Joffm
And therefore we do not usethe condition builder anymore.
If you want to use it, you have to create a new scenario to have the AND condition.

Nowadays we use Expression Manager/Script.
Or do you use a LimeSurvey version that doesn't have this included?

I have a equation question that gives me the age of a participant.

Did you calculate from his date of birth, or how?

Okay, the equation may be called "age"
Here you just have to type into your relevance equation of the question:
age>11 and age<50

Joffm


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

Please Log in to join the conversation.

More
1 month 2 weeks ago #199691 by holch
I would forget about the condition editor as quickly as possible. You obviously already know how to use Expression Manager/Script, as you are using it for an equation question.

Use relevance equations instead of conditions. Much more flexible and a lot quicker in my opinion.

Just put an equation in the relevance equation that will show it only if respondents are between 12 and 49.

Code could look like this (not tested and you'll have to adapt it to your survey of course):
age >= 12 AND age <=49

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 month 2 weeks ago #199692 by holch
Ok, Joffm beat me by a couple of minutes. ;-)

Same approach, slightly different formula. Should both work.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 month 2 weeks ago - 1 month 2 weeks ago #199695 by arnaudbore
Thank you guys for all your answers. It works pretty well but for some reasons if I add another condition, it doesn't seem to take into account the first condition, neither the third condition but when the second condition are met the question show up. :silly: :blink:

{(age>11 and age<50) or (age>49 and (QMenopause=="Y" and QMenopauseYear=="N")) or (age>49 and QMenopause=="N") }
Last edit: 1 month 2 weeks ago by arnaudbore.

Please Log in to join the conversation.

More
1 month 2 weeks ago #199697 by holch
What is the first, second and third condition?
1. (age>11 and age<50)
2. (age>49 and (QMenopause=="Y" and QMenopauseYear=="N"))
3. (age>49 and QMenopause=="N")

?

Please provide a LSS file with only the questions that are relevant for the problema so we can check.

I don't see an obvious problem in your code right now.

Do the 1st and 3rd condition work on their own? Have you tested them without the other conditions, just to make sure that each single condition works?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 month 2 weeks ago #199698 by arnaudbore
I checked the first one alone and it worked. Here is the lss file.


Thank you in advance for your help.

Arnaud
Attachments:

Please Log in to join the conversation.

More
1 month 2 weeks ago #199700 by holch
My first guess would be that the problem is that you are showing all questions on one screen. Not the best approach anyway.

But I'll need to do some research to check this.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 month 2 weeks ago #199701 by holch
And which is the question with the problem? You have sent a file with a lot of questions and so far I couldn't find the one with the relevance equation that doesn't work:
{(age>11 and age<50) or (age>49 and (QMenopause=="Y" and QMenopauseYear=="N")) or (age>49 and QMenopause=="N") }

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 month 2 weeks ago #199703 by holch
Found it. If you look at the relevance equations before you'll see the code highlighting. The relevance equation in the question "G3Q0012" has no highlighting at all. This usually means it hasn't been recognized as an equation.

So the problem was probably that you had a space at the end of your equation code and thus LS didn't understand it.

Your version:


Without the space at the end:


Haven't checked the actual function of the relevance equation, but the way it was it couldn't work, because the conditions in the relevance equation were not considered.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Attachments:

Please Log in to join the conversation.

More
1 month 2 weeks ago #199704 by arnaudbore
Sorry, here is a short version of the survey.
Attachments:

Please Log in to join the conversation.

More
1 month 2 weeks ago #199706 by arnaudbore
Even with this modification, the conditions 1 and 3 are not working properly.

Please Log in to join the conversation.

More
1 month 2 weeks ago #199707 by holch
OK, so there seem to be other problems. I thought this might be it.

Then some more testing will be required. Had hoped that the solution was that easy. ;-)

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

More
1 month 2 weeks ago #199708 by arnaudbore
That's why I added the question test into my survey to be able to see/debug the question G3Q0012... but so far it didn't help.

Please Log in to join the conversation.

More
1 month 2 weeks ago #199709 by Joffm
And you could shorten your relevance equation to
(age>11 and age<50) or (QMenopauseYear.NAOK=="N" or QMenopause.NAOK=="N")

In my opinion - tested several times - this works fine.

Joffm

By the way: your age calculation fails if I was born in 1901.


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

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now