Welcome to the LimeSurvey Community Forum

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

condition designer "and" & "or" limitations

  • joeschwab
  • joeschwab's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 1 month ago #226358 by joeschwab
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 3.18.0+190923
Own server or LimeSurvey hosting: Dedicated WHM/Cpanel CentOS
Survey theme/template: Vanilla / Fruity
==================
Howdy folks!
We have an eligibility criteria condition that is not especially complex in our screener survey, but some of the questions involved have multiple choice options, which adds a little bit of complexity. It seems like it should be doable with the condition designer, but I am struggling to get the logic to work correctly. I believe part of the issue is the inability to define "and" vs "or" within condition scenarios. I have tried building the condition initially in the condition designer, and then editing manually, but that doesn't seem to help.

The desired logic would look something like this:
((Qage.NAOK < 14 or Qage.NAOK > 18) or (Q2.NAOK >= 16))
or
(((Q3.NAOK == 1) and (Q4_SQ001.NAOK == "Y" and Q4_SQ002.NAOK != "Y" and Q4_SQ003.NAOK != "Y" and Q4_SQ004.NAOK != "Y" and Q4_SQ005.NAOK != "Y" and Q4_SQ006.NAOK != "Y" and Q4_SQ007.NAOK != "Y") and (Qsex.NAOK == 1))
and 
((Q12_SQ002.NAOK == "Y" or Q12_SQ003.NAOK == "Y" or Q12_SQ004.NAOK == "Y" or Q12_SQ005.NAOK == "Y" or Q12_SQ006.NAOK == "Y" or Q12_SQ007.NAOK == "Y" or Q12_SQ008.NAOK == "Y" or Q12_SQ010.NAOK == "Y" or Q12_SQ011.NAOK == "Y”) 
  or 
(Q11_SQ003.NAOK == "Y" or Q11_SQ004.NAOK == "Y" or Q11_SQ005.NAOK == "Y" or Q11_SQ006.NAOK == "Y" or Q11_SQ007.NAOK == "Y" or Q11_SQ008.NAOK == "Y" or Q11_SQ009.NAOK == "Y" or Q11_SQ010.NAOK == "Y" or Q11_SQ011.NAOK == "Y" or Q11_SQ012.NAOK == "Y")))

So, I think my question is: Is there a way to control and vs or within the condition designer?

It's entirely possible I am missing some important concept about how logic works in limesurvey, so any help / information or direction would be greatly appreciated. We are also willing to compensate for your time.

I have also attached my .lss file. The question that contains the logic in question is INELIGIBLEEQ

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #226359 by holch
I'll have a look, when I have some time. But whenever it comes to complex screenout criteria I would always define eligability in an equation type question (later hidden) and then only check the output of this equation question to base the condition on.

Quicker to implement, has less restrictions, better to troubleshoot.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #226362 by Joffm
To add something:
You seem to use this equation to handle a quota.

As @holch:
You should use an equation and set your quota on the equation.
And using the built-in functions you can shorten your equation to

{if((Qage.NAOK < 14 or Qage.NAOK > 18 or Q2.NAOK >= 16) or ((Q3.NAOK == 1 and Q4_Y001.NAOK=="Y" and count(that.Q4.sq_SQ.NAOK)==0 and Qsex.NAOK == 1) and (count(that.Q12.sq_SQ.NAOK)>0)) or (count(that.Q11.sq_SQ.NAOK)>0),1,2)}

Here I recoded
in Q11:
SQ001 to Y001
SQ002 to Y002

in Q12:
SQ001 to Y001.

This to be able to use "that.Q11.sq_SQ" and "that.Q12.sq_SQ".

Now you get to possible results of INELIGIBLEEQ:
1: screenout
2: fine

Now you set your quota accordingly.

Joffm

 

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

Please Log in to join the conversation.

  • joeschwab
  • joeschwab's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 1 month ago #226363 by joeschwab
Replied by joeschwab on topic condition designer "and" & "or" limitations
Thanks Holch. That essentially what we are doing here. This InelligibleEG question does most of the logic, and originally was contained in the equation question, but after having issues with the logic, i thought being able to use the condition designer might be helpful.

At the end of the screener, we use a condition to display a response.

Please Log in to join the conversation.

  • joeschwab
  • joeschwab's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 1 month ago #226365 by joeschwab
Replied by joeschwab on topic condition designer "and" & "or" limitations
Thanks Joffm, Im not familiar with quotas, are there any other useful resources besides the limesurvey documentation that you could reccomend?

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #226371 by Joffm
Hi,
to set a simple, single quota is really easy and it is shown in the manual quite well.

Always consider what  "quota" means.
You only want to have a certain amount of participants who answered a question in a predefined way.
Let's say: 
50 women, 20 men
The gender question was QSex with the answer options 1 = female, 2 = male
So you set one quota 
Name of quota: QFemale
Limit: 50 




And you add the answer
QSex==2
 

The same procedure for males.

Now you want to screen out anybody who doesn't fulfill your conditions.
Of course, here the limit has to be "0". You want to have no person at all in your survey with this answers.

So in this example you would screeenout all women.

Okay, now your survey.
This is a bit different as you want not only to show a message to the screened out persons but capture an email address.
Therefore you have to set the already shown function as relevance equation of Q10, that it is shown to persons who are going to be screended out., and the insert an equation to create a value that you use for your quota.

Here an example.
 

File Attachment:

File Name: limesurvey... (1).lss
File Size:137 KB


I am not really sure if your condition is correct (as I do not exactly know who is in and who is out. - QSex))

Joffm

 

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

Please Log in to join the conversation.

  • joeschwab
  • joeschwab's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 1 month ago #226439 by joeschwab
Replied by joeschwab on topic condition designer "and" & "or" limitations
Thanks Joffm!

Our criteria is pts younger than 14 or older than 18 and who have graduated highschool are ineligible .

our criteria at Q4 is exclusively white/caucasian are ineligible, but multiple choice responses that include white and another choice are eligible.

at Q12 exclusively heterosexual (Q12_SQ001 == Y) is ineligible, but multiple choice responses including heterosexual are eligible.

and similarly, at Q11, exclusively cisgender male/female - multiple choice responses including heterosexual are eligible.

We have logic on the end screen message to either display a thank you message (screenout) or redirect to another survey.

A the moment the multiple choice logic doesn't seem to work as intended.

I sent you a private message as well to see if you are available and interested in contracting to help us out.

Thx

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago - 3 years 1 month ago #226442 by Joffm
Hi,
so people are screened out, if
1. wrong age -> (QAge<14 AND Qage>18)
or
2. wrong grade -> (Q2>=16)
or 
3. only white, nothing else -> (Q4_Y001=="Y" and count(that.Q4.sq_SQ)==0) 
("white" is not eligible, "white" and "black" is eligible, "black" and "asian" is eligible)
or
4. only hetero, nothing else -> (Q12_Y001=="Y" and count(that.Q12.sq_SQ)==0)
("hetero" is not eligible, "hetero" and "asexual" is eligible, "gay" and "lesbian" is eligible)
or
5. only cis, nothing else -> (count(that.Q11.sq_Y)>0 and count(that.Q11.sq_SQ)==0)
("cis male", "cis male" and "cis female" is not eligible, "cis male" and "AGender" is eligible, "Questioning" and "Pangender" is eligible)

Now you have all conditions that screen out a person
(Qage.NAOK<14 AND Qage.NAOK>18) OR (Q2.NAOK>=16) OR (Q4_Y001.NAOK=="Y" and count(that.Q4.sq_SQ.NAOK)==0) OR (Q12_Y001.NAOK=="Y" and count(that.Q12.sq_SQ.NAOK)==0) OR (count(that.Q11.sq_Y.NAOK)>0 and count(that.Q11.sq_SQ.NAOK)==0)

You may use it in the equation to get a value to screen out persons
{if((Qage.NAOK<14 AND Qage.NAOK>18) OR (Q2.NAOK>=16) OR (Q4_Y001.NAOK=="Y" and count(that.Q4.sq_SQ.NAOK)==0) OR (Q12_Y001.NAOK=="Y" and count(that.Q12.sq_SQ.NAOK)==0) OR (count(that.Q11.sq_Y.NAOK)>0 and count(that.Q11.sq_SQ.NAOK)==0),1,2)}
1: screen out
2: proceed

Now you should be able to adapt it if some conditions are changed.
In the equation combine all conditions that screen out a person with OR and if one of those are TRUE the whole equation is TRUE and you get a result.

By the way:
What is the difference if I select in Q4
(white and black and asian) vs (more than one race)

And in the examples above I showed some - in my opinion - strange, but obviously allowed answer options.

And, of course, how do you want to handle the "No answers - 9998"?

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 1 month ago by Joffm.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #226448 by Joffm
HI,
you saw that I understood your "exclusively" in the LimeSurvey way.
"Exclusive option" means: Only this and nothing else.

But if your
our criteria at Q4 is exclusively white/caucasian are ineligible, but multiple choice responses that include white and another choice are eligible
means "everything except 'white/caucasian' (maybe with other choices) is screened out"
all other subquestions are irrelevant.

And the equation shortens to
{if(
(Qage.NAOK<14 AND Qage.NAOK>18)   -> wrong age
OR Q2.NAOK>=16  -> wrong grade
OR Q4_Y001.NAOK!="Y"  -> not "white/caucasian"
OR Q12_Y001.NAOK!="Y"  -> not "hetero"
OR count(that.Q11.sq_Y.NAOK)==0  -> not "cis"
,1,2)}

{if((Qage.NAOK<14 AND Qage.NAOK>18) OR Q2.NAOK>=16 OR Q4_Y001.NAOK!="Y" OR Q12_Y001.NAOK!="Y" OR count(that.Q11.sq_Y.NAOK)==0,1,2)}

Joffm

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

Please Log in to join the conversation.

  • joeschwab
  • joeschwab's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 1 month ago #226482 by joeschwab
Replied by joeschwab on topic condition designer "and" & "or" limitations
Hello! Thanks again for your help and patience. I greatly appreciate it!

I apologize for confusion and if this is redundant. I will try to explain more clearly:

Race:
If a person chooses only "white/caucasian", they are not eligible.
However, if a person chooses white/caucasian and black, asian or any other race, they are still eligible.

Gender Identity:
If a person chooses only cisgender girl or cisgender boy (but not both) they are not eligible.
if a person chooses cisgender girl or cisgender boy and trans / nonbinary or any other the other response (including Do not want to answer) combinations they are still eligible

Sexual Identity:
if a person chooses heterosexual only, they are not eligible.
if they choose heterosexual and any other response (including Do not want to answer), they are still eligible.

The count function is new to me, but I think I am understanding the way you are using it:

count(that.Q4.sq_SQ.NAOK)==0

My understanding is that If any of the subquestions that begin with SQ are selected, the count would add up to more than 0. is that correct? 

If so, then this ( Q4_Y001.NAOK  == "Y" and count(that.Q4.sq_SQ.NAOK)==0)
would return true if a participant chooses white/caucasian and chooses no other subquestions, but false if the SQ subquestions add up to greater than 0. This is pretty clever!

However, I realized changing the subquestion codes SQ001 to Y001 poses a few problems. Wwe are currently collecting responses in this survey, so changing the structure might make re-importing current responses impossible after the survey is disabled to make the change. We also may have some problems in our data analysis in reporting on these variables if the names change.





 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 1 month ago #226497 by Joffm

If a person chooses only "white/caucasian", they are not eligible.

That is how I understood.
So neglect the second post .

If so, then this (Q4_Y001.NAOK == "Y" and count(that.Q4.sq_SQ.NAOK)==0)
would return true if a participant chooses white/caucasian and chooses no other subquestions, but false if the SQ subquestions add up to greater than 0. This is pretty clever!

Exactly this. These variables "self" and "that" can ease your life tremendously.
And therefore I changed the code.

However, I realized changing the subquestion codes SQ001 to Y001 poses a few problems. Wwe are currently collecting responses in this survey, so changing the structure might make re-importing current responses impossible after the survey is disabled to make the change. We also may have some problems in our data analysis in reporting on these variables if the names change.

Re-importing? You could avoid problems if you do not rename the code "SQ001" to "Y001", but create a new code and set "SQ001" to "not displayed" by subquestion relevance.
Data analysis? I should say, one small script in your analysis tool to merge the two columns, or recode.
Nevertheless: You did not mention this before.

Then you may do it the hard way.
Because "that" expands to all columns that contain the characters after "sq"

Don't use "that", but list all variables one by one.
(Q4_SQ001.NAOK == "Y" and count(Q4_SQ002.NAOK,Q4_SQ003.NAOK,Q4_SQ004.NAOK,Q4_SQ005.NAOK,...)==0)
as the manual shows:
 

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: joeschwab

Please Log in to join the conversation.

  • joeschwab
  • joeschwab's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 1 month ago #226571 by joeschwab
Replied by joeschwab on topic condition designer "and" & "or" limitations
Thanks Joffm!
You have given me great information and direction. Your help is very greatly appreciated!

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose