Welcome to the LimeSurvey Community Forum

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

Relevance equation - Date higher than X & Question Answer is Y

  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164554 by rbernhardthki
In another topic I got help so that I can show a question of the installation date is within 60 days. Problem is I have another criteria for this question, if Manufacturer is Y then it is only 30 days instead of 60 like everyone else.

When I add the Relevance equation it works fine, but the issue is that if the date is within 30 days, it displays both questions. When I add a condition manually to say Question X's answer has to equal to Y. It will overwrite my below date check. Is it possible to add an IF to the below so that it works? Or how can I do it?

60 Days
(strtotime(date('Y-m-d'))-strtotime(INSERTANS:669123X301X2381)) >= (60*60*24*60)

30 Days
(strtotime(date('Y-m-d'))-strtotime(INSERTANS:669123X301X2381)) >= (60*60*24*30)

Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #164561 by tpartner
Assign the 30/60 number in another equation question (lets call it "warrantyPeriod") and the reference that in your relevance equation.

Code:
(strtotime(date('Y-m-d'))-strtotime(INSERTANS:669123X301X2381)) >= (60*60*24*warrantyPeriod)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164572 by rbernhardthki
Not sure im following.

I have a question called warranty type with 3 answer options. Commissioning, Parts only, Parts Labour & Travel.

There is another question with different Manufacturers listed.

If Commissioning and X OEM is selected I need 30 days, all others are 60 days.

How do I make a new question so that I can reference the 30/60 as you mentioned?

Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #164579 by tpartner
It's impossible for me to give an equation code example without knowing your survey set-up and question/answer codes but here is a sample survey that should give you the idea.

Selecting the first option in Q1 and Q2 will result in a warranty period of 30 days, all other combination of selections result in 60 days.

File Attachment:

File Name: limesurvey...6928.lss
File Size:16 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #164580 by Joffm

If Commissioning and X OEM is selected I need 30 days, all others are 60 days.


Read about the if-statement in the manual.

Then you create an equation (lets call it "warrantyPeriod") like

{if (manufacturer=="X OEM",30,60)}

Afterwards you can use this variable.

Regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164582 by rbernhardthki
The survey is somewhat more complicated than that. If you could have a look at the attached, that is basically what I need working.

Q1 = warranty type

Q2 = OEM (although on the real survey this is 3 separate question, one for each warranty type)


Then I have 4 text display options, depending on what was selected as the text needs to be different for each.

Now the issue is I have is that it displays the other 3 text displays no matter what date option is selected. The corresponding text display is hidden is the date is within the 60 days.

Any idea what I am doing incorrectly?

File Attachment:

File Name: limesurvey...9282.lss
File Size:25 KB
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago - 6 years 1 month ago #164584 by Joffm
Hi,
set the relevance of Q3, Q4,... not only to "equationX" but to "equationX!=0" (or "equationX==1").

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 1 month ago by Joffm.
The topic has been locked.
  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164588 by rbernhardthki
Great stuff! Works great.

One more thing, now I have a question group that is empty if the date is correct. Is it possible to skip/hide question groups where all answers are hidden?
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago - 6 years 1 month ago #164595 by Joffm
Just set the relevance of the group.
Should be something like:
(equation1==1) or (equation2==1) or ...

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 1 month ago by Joffm.
The topic has been locked.
  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164598 by rbernhardthki
Cheers mate, you guys are the best
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose