equation question - syntax issue

More
2 weeks 3 days ago #173411 by marektondryk
marektondryk created the topic: equation question - syntax issue


I have 3 questions (q1, q2, q3) radio list each one with answers 'yes' (A1) and 'no' (A2).
I want answer returned from equation question for condition:
{if answer for q1=A2 and answer for q2=A2 and answer for q3=A2 than "red" or
if answer for q1=A1 and answer for q2=A2 and answer for q3=A2 than "green" or
if answer for q1=A1 and answer for q2=A1 and answer for q3=A2 than "blue" or
if answer for q1=A1 and answer for q2=A1 and answer for q3=A1 than "yellow"}

How should this equation question look like?
Attachments:

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago - 2 weeks 2 days ago #173415 by DenisChenu
DenisChenu replied the topic: equation question - syntax issue
I do :
{join(
if(q1=="A2" and q2=="A2" and q3=="A2",'red',''),
if(q1=="A1" and q2=="A2" and q3=="A2",'green',''),
if(q1=="A1" and q2=="A1" and q3=="A2",'blue',''),
if(q1=="A1" and q2=="A1" and q3=="A1",'yellow',''),
'')}
Because it's more simple to understand and fix then imbricated if : manual.limesurvey.org/Expression_Manager...Conditional_Logic.29

(corrected)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last Edit: 2 weeks 2 days ago by DenisChenu. Reason: Use == not = silly boy
The following user(s) said Thank You: marektondryk

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago #173418 by jelo
jelo replied the topic: equation question - syntax issue

However, we recommend using the join() function for concatenation, as that makes your intent more clear, and avoids unexpected results if you were expecting strings but got numbers instead (or vice versa).

manual.limesurvey.org/Expression_Manager#Operators

Are you a student conducting a survey? If yes, tell me why you use LimeSurvey?
www.limesurvey.org/forum/development/116...y-you-use-limesurvey
The following user(s) said Thank You: marektondryk

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago #173421 by tpartner
tpartner replied the topic: equation question - syntax issue
Why the join function? Since they are mutually exclusive, why not simply use four IF() statements (not nested)?

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: marektondryk

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago - 2 weeks 2 days ago #173422 by DenisChenu
DenisChenu replied the topic: equation question - syntax issue

tpartner wrote: Why the join function? Since they are mutually exclusive, why not simply use four IF() statements (not nested)?

Maybe in future Equation question type save line feed ;).

But currently : you're right, can be done with
{if(q1=="A2" and q2=="A2" and q3=="A2",'red','')}
{if(q1=="A1" and q2=="A2" and q3=="A2",'green','')}
{if(q1=="A1" and q2=="A1" and q3=="A2",'blue','')}
{if(q1=="A1" and q2=="A1" and q3=="A1",'yellow','')}

(Edited/corrected)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last Edit: 2 weeks 2 days ago by DenisChenu. Reason: Use == not = silly boy !
The following user(s) said Thank You: marektondryk

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago #173446 by marektondryk
marektondryk replied the topic: equation question - syntax issue
Thanks guys :)
I put code:
{if(q1="A2" and q2="A2" and q3="A2",'red','')}
{if(q1="A1" and q2="A2" and q3="A2",'green','')}
{if(q1="A1" and q2="A1" and q3="A2",'blue','')}
{if(q1="A1" and q2="A1" and q3="A1",'yellow','')}

into new equation question and I don't get yellow,blue, etc. answer...
What should I do???? :(

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago #173448 by holch
holch replied the topic: equation question - syntax issue
Send a LSS file with what you have done.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago #173455 by marektondryk
marektondryk replied the topic: equation question - syntax issue

File Attachment:

File Name: test.lss
File Size:16 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago - 2 weeks 3 days ago #173457 by vkuzmin
vkuzmin replied the topic: equation question - syntax issue
Use dual equality == to compare values
UPD: And use quotes instead of apostrophes.
Last Edit: 2 weeks 3 days ago by vkuzmin.
The following user(s) said Thank You: marektondryk

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago #173471 by tpartner
tpartner replied the topic: equation question - syntax issue

Use dual equality == to compare values

Duh...that's a rookie mistake, not catching that :)

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: marektondryk

Please Log in or Create an account to join the conversation.

More
2 weeks 2 days ago #173479 by marektondryk
marektondryk replied the topic: equation question - syntax issue
Thanks!!!!! :) Works GREAT!!!

Please Log in or Create an account to join the conversation.

More
2 weeks 2 days ago #173482 by DenisChenu
DenisChenu replied the topic: equation question - syntax issue

tpartner wrote:

Use dual equality == to compare values

Duh...that's a rookie mistake, not catching that :)

Arg … my mistake … :S

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
2 weeks 1 day ago #173571 by marektondryk
marektondryk replied the topic: equation question - syntax issue
Is it possibe to set condiotion e.g.
{if(q1=="A2" and q2=="A1" and q3=="A1",'Yor answers aren't logical','')}
which doesn't allow to click button NEXT?

Please Log in or Create an account to join the conversation.

More
2 weeks 1 day ago #173574 by tpartner
tpartner replied the topic: equation question - syntax issue
Depending on the question type, you can use the Question validation equation and Tip for whole question validation equation - manual.limesurvey.org/Question_type_-_Li...28em_validation_q.29

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
2 weeks 1 day ago #173575 by marektondryk
marektondryk replied the topic: equation question - syntax issue
May I use this for 3 radio list questions condition or just for one?

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!