- Posts: 105
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
equation question - syntax issue
- marektondryk
- Topic Author
- Offline
- Premium Member
Less
More
5 years 6 months ago #173411
by marektondryk
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?
equation question - syntax issue was created by marektondryk
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:
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
5 years 6 months ago - 5 years 6 months ago #173415
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 equation question - syntax issue
I do :
Because it's more simple to understand and fix then imbricated if :
manual.limesurvey.org/Expression_Manager...Conditional_Logic.29
(corrected)
Code:
{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',''), '')}
(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 , plugin development .
I don't answer to private message.
Last edit: 5 years 6 months ago by DenisChenu. Reason: Use == not = silly boy
The following user(s) said Thank You: marektondryk
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
5 years 6 months ago #173418
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic equation question - syntax issue
manual.limesurvey.org/Expression_Manager#OperatorsHowever, 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).
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: marektondryk
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
5 years 6 months ago #173421
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 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
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
5 years 6 months ago - 5 years 6 months ago #173422
by DenisChenu
But currently : you're right, can be done with
(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 , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic equation question - syntax issue
Maybe in future Equation question type save line feed .tpartner wrote: Why the join function? Since they are mutually exclusive, why not simply use four IF() statements (not nested)?
But currently : you're right, can be done with
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','')}
(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 , plugin development .
I don't answer to private message.
Last edit: 5 years 6 months ago by DenisChenu. Reason: Use == not = silly boy !
The following user(s) said Thank You: marektondryk
The topic has been locked.
- marektondryk
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 105
- Thank you received: 0
5 years 6 months ago #173446
by marektondryk
Replied by marektondryk on 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????
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????
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
5 years 6 months ago #173448
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic equation question - syntax issue
Send a LSS file with what you have done.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- marektondryk
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 105
- Thank you received: 0
5 years 6 months ago #173455
by marektondryk
Replied by marektondryk on topic equation question - syntax issue
Attachments:
The topic has been locked.
- vkuzmin
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 6
5 years 6 months ago - 5 years 6 months ago #173457
by vkuzmin
Replied by vkuzmin on topic equation question - syntax issue
Use dual equality == to compare values
[strike]UPD: And use quotes instead of apostrophes.[/strike]
[strike]UPD: And use quotes instead of apostrophes.[/strike]
Last edit: 5 years 6 months ago by vkuzmin.
The following user(s) said Thank You: marektondryk
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
5 years 6 months ago #173471
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 equation question - syntax issue
Duh...that's a rookie mistake, not catching thatUse dual equality == to compare values
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
The topic has been locked.
- marektondryk
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 105
- Thank you received: 0
5 years 6 months ago #173479
by marektondryk
Replied by marektondryk on topic equation question - syntax issue
Thanks!!!!! Works GREAT!!!
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
5 years 6 months ago #173482
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 equation question - syntax issue
Arg … my mistake … :Stpartner wrote:
Duh...that's a rookie mistake, not catching thatUse dual equality == to compare values
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.