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

1 year 4 months ago #164554
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

LimeSurvey Partners
1 year 4 months 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.

(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.
Official LimeSurvey Partner - partnersurveys.com

1 year 4 months ago #164572
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

1 year 4 months 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.
Official LimeSurvey Partner - partnersurveys.com
##### Attachments:

1 year 3 months ago #164580 by Joffm

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

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

1 year 3 months ago #164582
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
##### Attachments:

1 year 3 months ago - 1 year 3 months 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: 1 year 3 months ago by Joffm.

1 year 3 months ago #164588
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?

1 year 3 months ago - 1 year 3 months 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: 1 year 3 months ago by Joffm.