- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
combining multiple conditions (including date) to display/hide questions
- GHN
- Topic Author
- Offline
- New Member
Less
More
3 years 6 months ago #208071
by GHN
combining multiple conditions (including date) to display/hide questions was created by GHN
Hi Everyone,
I'm looking for some help with creating a relevance equation with conditions from 2 previous questions, the first of which (A1) is a date picker and the second is a dropdown (B1).
Question B2 should only appear when the date selected is less than 6 months ago AND either the first (A01) or second (A02) option in the dropdown has been selected.
I've been playing about with variations of the below equation and can't seem to get it to work. Any help that anyone can give me would be gratefully received.
((A1 and (strtotime(date('Y-m-d')) - strtotime(A1) < 15811200))) and ((B1.NAOK == "A01" or B1.NAOK == "A02"))
I'm looking for some help with creating a relevance equation with conditions from 2 previous questions, the first of which (A1) is a date picker and the second is a dropdown (B1).
Question B2 should only appear when the date selected is less than 6 months ago AND either the first (A01) or second (A02) option in the dropdown has been selected.
I've been playing about with variations of the below equation and can't seem to get it to work. Any help that anyone can give me would be gratefully received.
((A1 and (strtotime(date('Y-m-d')) - strtotime(A1) < 15811200))) and ((B1.NAOK == "A01" or B1.NAOK == "A02"))
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13033
- Thank you received: 4009
3 years 5 months ago #208080
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic combining multiple conditions (including date) to display/hide questions
Hi,
I do not know what is the meaning of this:
((A1 and (strtotime(date('Y-m-d')) - strtotime(A1) < 15811200))) and ((B1.NAOK == "A01" or B1.NAOK == "A02"))
but this works
(strtotime(date('Y-m-d')) - strtotime(A1) < 15811200) and (B1.NAOK == "A01" or B1.NAOK == "A02")
Joffm
I do not know what is the meaning of this:
((A1 and (strtotime(date('Y-m-d')) - strtotime(A1) < 15811200))) and ((B1.NAOK == "A01" or B1.NAOK == "A02"))
but this works
(strtotime(date('Y-m-d')) - strtotime(A1) < 15811200) and (B1.NAOK == "A01" or B1.NAOK == "A02")
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- GHN
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
3 years 5 months ago - 3 years 5 months ago #208102
by GHN
Replied by GHN on topic combining multiple conditions (including date) to display/hide questions
Thanks for your quick response Joffm. I can't seem to get your solution to work either...
On its own, each condition works perfectly i.e.
(strtotime(date('Y-m-d')) - strtotime(A1) < 15811200) <- this works
and
(B1.NAOK == "A01" or B1.NAOK == "A02") <- this works
but when I combine the two the question doesn't appear at all...
I'm stumped.
On its own, each condition works perfectly i.e.
(strtotime(date('Y-m-d')) - strtotime(A1) < 15811200) <- this works
and
(B1.NAOK == "A01" or B1.NAOK == "A02") <- this works
but when I combine the two the question doesn't appear at all...
I'm stumped.
Last edit: 3 years 5 months ago by GHN. Reason: punctuatuion
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13033
- Thank you received: 4009
3 years 5 months ago #208108
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic combining multiple conditions (including date) to display/hide questions
And if you don't show us what you did we cannot find your mistake.
Send a lss export.
Joffm
Send a lss export.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13033
- Thank you received: 4009
3 years 5 months ago #208116
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic combining multiple conditions (including date) to display/hide questions
Because I do not see any issue with
(strtotime(date('Y-m-d')) - strtotime(A1) < 15811200) and (B1.NAOK == "A01" or B1.NAOK == "A02")
1. Date in range, dropdown not
2. Date not in range, dropdown in range
3. Date in range, dropdown in range
Joffm
(strtotime(date('Y-m-d')) - strtotime(A1) < 15811200) and (B1.NAOK == "A01" or B1.NAOK == "A02")
1. Date in range, dropdown not
2. Date not in range, dropdown in range
3. Date in range, dropdown in range
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- GHN
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
3 years 5 months ago #208117
by GHN
Replied by GHN on topic combining multiple conditions (including date) to display/hide questions
Thanks again for getting back to me, I've attached the lss file.
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13033
- Thank you received: 4009
3 years 5 months ago #208129
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic combining multiple conditions (including date) to display/hide questions
In your version:
put B1 into a separate group.
Between "Achievement" and "Housing". Or put it into another group.
Joffm
put B1 into a separate group.
Between "Achievement" and "Housing". Or put it into another group.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- GHN
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
3 years 5 months ago #208132
by GHN
Replied by GHN on topic combining multiple conditions (including date) to display/hide questions
Works like a charm, thank you for all your help Joffm.
Could you explain to me why it didn't work when question B1 was in the same group?
I'm wondering in case I encounter a similar situation in the future.
Thanks again
Could you explain to me why it didn't work when question B1 was in the same group?
I'm wondering in case I encounter a similar situation in the future.
Thanks again
The topic has been locked.