- Posts: 9
- Thank you received: 2
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Expression Manager big 'if' list
- redbeard
- Topic Author
- Offline
- New Member
Less
More
5 years 9 months ago #170864
by redbeard
Expression Manager big 'if' list was created by redbeard
Hi,
Thank you for taking the time to take a look at my question.
I have a question which asks users to pick a choice from a drop down list with 21 answers.
Depending on the answer, I want to give a score between 1 and 3. (score to be saved in DB)
I think it's possible to do this with a long 'if' statement, something like this (I have only put in the first 2 of 21 answers here):
Many thanks for any help on this
Thank you for taking the time to take a look at my question.
I have a question which asks users to pick a choice from a drop down list with 21 answers.
Depending on the answer, I want to give a score between 1 and 3. (score to be saved in DB)
I think it's possible to do this with a long 'if' statement, something like this (I have only put in the first 2 of 21 answers here):
Code:
{if(Q8 == 'AGRICULTURE, FORESTRY AND FISHING', '1', if(Q8 == 'MINING AND QUARRYING', '2', '3' ))}
- Is there a better way of doing this than a long if statement?
- The code above doesn't work - I have tried with and without the '
- Rather than using the answer text in the Expression, is it possible to use the Answer code?
Many thanks for any help on this
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
5 years 9 months ago #170865
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Expression Manager big 'if' list
Hi,
of course, you have to use the code.
And with only three different scores, it is something like:
{if(Q8==1 or Q8= or Q8==13,1,if(Q8==2 or Q8==4 or Q8==12,2,3))}
Best regards
Joffm
of course, you have to use the code.
And with only three different scores, it is something like:
{if(Q8==1 or Q8= or Q8==13,1,if(Q8==2 or Q8==4 or Q8==12,2,3))}
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: redbeard
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
5 years 9 months ago #170901
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 Expression Manager big 'if' list
Yes , you can
manual.limesurvey.org/Expression_Manager#Conditional_Equations
(see
manual.limesurvey.org/images/1/1f/Tailoring9.jpg
)
But with a lot of if, you can do someting like this :
But with a lot of if, you can do someting like this :
Code:
{join( if(Q8==1 or Q8==3 or Q8==13,1,''), if(Q8==2 or Q8==4 or Q8==12,2,''), if(Q8==1 and Q8==3 and Q8==13 and Q8==2 and Q8==4 and Q8==12) )}
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 following user(s) said Thank You: redbeard
The topic has been locked.