Equation - how can I assign individual ID's for different answer combinations?

More
1 year 2 days ago - 1 year 2 days ago #156822 by Sweden
Sweden created the topic: Equation - how can I assign individual ID's for different answer combinations?
Lets say that I have the following questions in my survey:

Multiple Choice (Question code: Q1)

1.
2.
3.

Yes/No (Question code: Q2)

Yes
No

Radio list (Question code: Q3)

1.
2.
3.


I want to assign individual ID's for different answer combinations e.g.:
IF Q1=2 AND Q2="Yes" AND Q3=1 THEN ID = 100
IF Q1=1 AND Q2="No" AND Q3=2 THEN ID = 200
IF Q1=1 AND Q2="Yes" AND Q3=3 THEN ID = 300

I have tried to use the question type "Equation" for this (would prefer this instead of javascript), but I just can't figure out how it works. I have looked in the manual etc. but I haven't found any good examples for my situation. Could someone please help me with the equation for the example above where questions codes are used (e.g. Q1_SQ002). One equation should be able to handle all three mentioned answer combinations. That means that the value stored in the database should be 100, 200 or 300 (or empty depending on the combination of answers).
Last Edit: 1 year 2 days ago by Sweden.

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

More
1 year 2 days ago - 1 year 2 days ago #156824 by DenisChenu
DenisChenu replied the topic: Equation - how can I assign individual ID's for different answer combinations?
1st remind : = is assign, and == is test.

IF Q1=2 AND Q2="Yes" AND Q3=1 THEN ID = 100
IF Q1=1 AND Q2="No" AND Q3=2 THEN ID = 200
IF Q1=1 AND Q2="Yes" AND Q3=3 THEN ID = 300

is (in a equation question type)
{ID=if(Q1==2 and Q2=="Yes" and Q3==1,100,
if(Q1==1 and Q2=="No" and Q3==2,200,
if(Q1==1 and Q2=="Yes" and Q3==3,300,"")
)
)}

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: 1 year 2 days ago by DenisChenu.
The following user(s) said Thank You: Sweden

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

More
1 year 2 days ago #156825 by Sweden
Sweden replied the topic: Equation - how can I assign individual ID's for different answer combinations?
Thanks! :) Your code worked after I changed a few things (for those who don't know - multiple choise and radio list don't use the value 1,2,3 etc. Instead use SQ001="Y", SQ002="N" etc. for multiple choise questions and ="A1", ="A2" etc. for radio list questions).

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

More
1 year 1 day ago #156827 by DenisChenu
DenisChenu replied the topic: Equation - how can I assign individual ID's for different answer combinations?
I just tranlate yor equation I Expression Manager

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.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!