- Posts: 16
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Yes and No if statement
- goolasso
- Topic Author
- Offline
- New Member
Less
More
4 years 4 months ago #191999
by goolasso
Yes and No if statement was created by goolasso
Hello.
I am trying to do a very simple if statement like this:
But If I test the survey it always anwer rrn even if I answer Yes to CMod3.
Am I doing any syntax error?
I am trying to do a very simple if statement like this:
Code:
{if ((CMod3=='Yes'),"rry","rrn")}
But If I test the survey it always anwer rrn even if I answer Yes to CMod3.
Am I doing any syntax error?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 4 months ago #192004
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 Yes and No if statement
You need to use the answer code for CMod3, not the answer label.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- goolasso
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
4 years 4 months ago #192005
by goolasso
Replied by goolasso on topic Yes and No if statement
Aaaahhhh, ok....
My answer label is CMod3, I have answer code A2 for yes and A3 for no.
How can I build my if statement?
My answer label is CMod3, I have answer code A2 for yes and A3 for no.
How can I build my if statement?
The topic has been locked.
- goolasso
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
4 years 4 months ago #192006
by goolasso
Replied by goolasso on topic Yes and No if statement
The topic has been locked.
- goolasso
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
4 years 4 months ago #192007
by goolasso
Replied by goolasso on topic Yes and No if statement
This is another example that is not working for CMod1
The topic has been locked.
- goolasso
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
4 years 4 months ago #192010
by goolasso
Replied by goolasso on topic Yes and No if statement
I used CMod1.shown instead of CMod1 and now is working!
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
4 years 4 months ago - 4 years 4 months ago #192016
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Yes and No if statement
As tpartner said, you should use the answer code.
{if ((CMod3=='A2'),"rry","rrn")}
Joffm
{if ((CMod3=='A2'),"rry","rrn")}
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 4 months ago by Joffm.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 4 months ago #192026
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 Yes and No if statement
If you use .shown, it will be different for different languages. It's safer to use the answer code as Joffm demonstrates.I used CMod1.shown instead of CMod1 and now is working!
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
4 years 4 months ago #192040
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Yes and No if statement
Maybe
{if ((CMod3.NAOK=='A2'),"rry","rrn")}
{if ((CMod3.NAOK=='A2'),"rry","rrn")}
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- goolasso
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
4 years 4 months ago #192048
by goolasso
Replied by goolasso on topic Yes and No if statement
Which is the difference with or without NAOK?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 4 months ago #192051
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 Yes and No if statement
If accessing variable that may be hidden via relevance, you need to use .NAOK ("no answer okay") so the variable is not undefined if hidden. It's not a bad practice to always use it - as far as I can tell, there is no performance penalty.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu
The topic has been locked.