- Posts: 40
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Recording on single Choice question
- mnelson
- Topic Author
- Offline
- Senior Member
Less
More
3 years 2 months ago #211077
by mnelson
Recording on single Choice question was created by mnelson
Hi,
I was consolidating gender questions into one single dummy question.I used the below function,it only works if Female selected because the second function overwrites the first one,how can I best execute this?
{GenderDummy1=if((genderid=="male" or gender==1),"1")}{GenderDummy1=if((genderid=="female" or gender==2) ,"2")}
LimeSurvey
Version 3.25.9
I was consolidating gender questions into one single dummy question.I used the below function,it only works if Female selected because the second function overwrites the first one,how can I best execute this?
{GenderDummy1=if((genderid=="male" or gender==1),"1")}{GenderDummy1=if((genderid=="female" or gender==2) ,"2")}
LimeSurvey
Version 3.25.9
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12904
- Thank you received: 3967
3 years 2 months ago - 3 years 2 months ago #211078
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Recording on single Choice question
The first is easy to understand. Of course will it overwrite.
Maybe you may save it by:
{GenderDummy1=if(genderid=="male" or gender==1,"1")}
{GenderDummy1=if(genderid=="female" or gender==2 ,"2", GenderDummy1)}
You should try.
But better:
{GenderDummy1=if(genderid=="male" or gender==1,1,2)}
if there is no other option. If it is not 1 then it is 2.
Otherwise (there is a third option) you should use a nested IF with the usual syntax {IF(condition,what if true, what if false)}
{GenderDummy1=if(genderid=="male" or gender==1,1,if(genderid=="female" or gender==2 ,2,0))}
Here you see that the FALSE part of the first IF is a new IF-statement.
The result will be:
1, if genderid == "male"
1, if gender == 1
2, if genderid == "female"
2, if gender == 2
0, if genderid != "male" and gender!=1 and genderid!="female" and gender!=2
Joffm
Maybe you may save it by:
{GenderDummy1=if(genderid=="male" or gender==1,"1")}
{GenderDummy1=if(genderid=="female" or gender==2 ,"2", GenderDummy1)}
You should try.
But better:
{GenderDummy1=if(genderid=="male" or gender==1,1,2)}
if there is no other option. If it is not 1 then it is 2.
Otherwise (there is a third option) you should use a nested IF with the usual syntax {IF(condition,what if true, what if false)}
{GenderDummy1=if(genderid=="male" or gender==1,1,if(genderid=="female" or gender==2 ,2,0))}
Here you see that the FALSE part of the first IF is a new IF-statement.
The result will be:
1, if genderid == "male"
1, if gender == 1
2, if genderid == "female"
2, if gender == 2
0, if genderid != "male" and gender!=1 and genderid!="female" and gender!=2
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 2 months ago by Joffm.
The topic has been locked.
- mnelson
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 1
3 years 2 months ago #211352
by mnelson
Replied by mnelson on topic Recording on single Choice question
Thanks you,this is working perfectly
The topic has been locked.