- Posts: 38
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Equation - Text display
- stemate1988
- Topic Author
- Offline
- Junior Member
Less
More
7 years 7 months ago #140134
by stemate1988
Equation - Text display was created by stemate1988
Just a quick one, I have an equation question and the formula below:
if(G1_Q0013 == 'A3', 'Correct', 'Incorrect') if(G1_Q0013 == 'A4', 'Correct', 'Incorrect') if(G1_Q0013 == 'A5', 'Correct', 'Incorrect')
This will give the text answer of (correct, incorrect, incorrect) or a variation of this in a different order
or it could display (incorrect,incorrect,incorrect).
Is there a way i can alter the formula above to only display one answer? That being correct or incorrect.
Cheers
if(G1_Q0013 == 'A3', 'Correct', 'Incorrect') if(G1_Q0013 == 'A4', 'Correct', 'Incorrect') if(G1_Q0013 == 'A5', 'Correct', 'Incorrect')
This will give the text answer of (correct, incorrect, incorrect) or a variation of this in a different order
or it could display (incorrect,incorrect,incorrect).
Is there a way i can alter the formula above to only display one answer? That being correct or incorrect.
Cheers
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12713
- Thank you received: 3924
7 years 7 months ago #140139
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Equation - Text display
Hi, stermate1988,
you get three answers because you have three conditions.
Remember how the "IF" works:
IF (some_condition, result if true, result if false).
So you have to merge your IF statements:
IF(G1_Q0013.NAOK=='A3', 'Correct', if(G1_Q0013.NAOK=='A4', 'Correct',if(G1_Q0013.NAOK=='A5','Correct','Incorrect'))).
But as I understand your statement:
If one the answers is 'A3' or 'A4' or 'A5' the result is 'Correct' otherwise 'Incorrect'.
So IMHO it's better just to say:
if(G1_Q0013.NAOK=='A3' or G1_Q0013.NAOK=='A4' or G1_Q0013.NAOK=='A4','Correct','Incorrect')
Best regards
Joffm
you get three answers because you have three conditions.
Remember how the "IF" works:
IF (some_condition, result if true, result if false).
So you have to merge your IF statements:
IF(G1_Q0013.NAOK=='A3', 'Correct', if(G1_Q0013.NAOK=='A4', 'Correct',if(G1_Q0013.NAOK=='A5','Correct','Incorrect'))).
But as I understand your statement:
If one the answers is 'A3' or 'A4' or 'A5' the result is 'Correct' otherwise 'Incorrect'.
So IMHO it's better just to say:
if(G1_Q0013.NAOK=='A3' or G1_Q0013.NAOK=='A4' or G1_Q0013.NAOK=='A4','Correct','Incorrect')
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- stemate1988
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
- Thank you received: 0
7 years 7 months ago #140143
by stemate1988
Replied by stemate1988 on topic Equation - Text display
Cheers for this Joffm,
I knew there would be a way of constructing this using the OR operators i just couldnt work it out.
It works anyway.
Much appreciated
I knew there would be a way of constructing this using the OR operators i just couldnt work it out.
It works anyway.
Much appreciated
The topic has been locked.