Welcome to the LimeSurvey Community Forum

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

Yes and No if statement

  • goolasso
  • goolasso's Avatar Topic Author
  • Offline
  • New Member
  • New Member
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:
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
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 months ago #192004 by tpartner
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
  • goolasso's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
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?
The topic has been locked.
  • goolasso
  • goolasso's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 months ago #192006 by goolasso
Replied by goolasso on topic Yes and No if statement
The topic has been locked.
  • goolasso
  • goolasso's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
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
  • goolasso's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
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
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 months ago - 4 years 4 months ago #192016 by Joffm
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

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
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 months ago #192026 by tpartner
Replied by tpartner on topic Yes and No if statement

I used CMod1.shown instead of CMod1 and now is working!

If you use .shown, it will be different for different languages. It's safer to use the answer code as Joffm demonstrates.

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
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 months ago #192040 by DenisChenu
Replied by DenisChenu on topic Yes and No if statement
Maybe
{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
  • goolasso's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
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
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 months ago #192051 by tpartner
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.

Lime-years ahead

Online-surveys for every purse and purpose