- Posts: 29
- Thank you received: 1
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
- Topic Author
- Offline
- Junior Member
Less
More
6 years 1 month ago #164554
by rbernhardthki
Relevance equation - Date higher than X & Question Answer is Y was created 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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
6 years 1 month ago #164561
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Relevance equation - Date higher than X & Question Answer is Y
Assign the 30/60 number in another equation question (lets call it "warrantyPeriod") and the reference that in your relevance equation.
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
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 29
- Thank you received: 1
6 years 1 month ago #164572
by rbernhardthki
Replied by rbernhardthki on topic Relevance equation - Date higher than X & Question Answer is Y
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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
6 years 1 month ago #164579
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Relevance equation - Date higher than X & Question Answer is Y
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.
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.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
6 years 1 month ago #164580
by Joffm
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
Replied by Joffm on topic Relevance equation - Date higher than X & Question Answer is Y
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
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 29
- Thank you received: 1
6 years 1 month ago #164582
by rbernhardthki
Replied by rbernhardthki on topic Relevance equation - Date higher than X & Question Answer is Y
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?
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?
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
6 years 1 month ago - 6 years 1 month ago #164584
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Relevance equation - Date higher than X & Question Answer is Y
Hi,
set the relevance of Q3, Q4,... not only to "equationX" but to "equationX!=0" (or "equationX==1").
Joffm
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
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 29
- Thank you received: 1
6 years 1 month ago #164588
by rbernhardthki
Replied by rbernhardthki on topic Relevance equation - Date higher than X & Question Answer is Y
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?
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
6 years 1 month ago - 6 years 1 month ago #164595
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Relevance equation - Date higher than X & Question Answer is Y
Just set the relevance of the group.
Should be something like:
(equation1==1) or (equation2==1) or ...
Joffm
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
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 29
- Thank you received: 1
6 years 1 month ago #164598
by rbernhardthki
Replied by rbernhardthki on topic Relevance equation - Date higher than X & Question Answer is Y
Cheers mate, you guys are the best
The topic has been locked.