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

More
3 years 6 months ago #208071 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"))
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #208080 by Joffm
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

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
3 years 5 months ago - 3 years 5 months ago #208102 by GHN
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.
Last edit: 3 years 5 months ago by GHN. Reason: punctuatuion
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #208108 by Joffm
And if you don't show us what you did we cannot find your mistake.
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
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #208116 by Joffm
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

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
3 years 5 months ago #208117 by GHN
Thanks again for getting back to me, I've attached the lss file.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #208129 by Joffm
In your version:
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.
More
3 years 5 months ago #208132 by GHN
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
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose