- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
equation to test coherence between two answers (array with subquestion)
- lefebvremarianne
- Topic Author
- Offline
- New Member
Less
More
6 years 5 months ago #160430
by lefebvremarianne
equation to test coherence between two answers (array with subquestion) was created by lefebvremarianne
Hello
I need to check whether the answers to Qu1 is coherent with the answer in Qu7. It is coherent if is the opposite (A in Qu1 and B in Qu7 or B in Qu1 and A in Qu7 ).
The questions 1 and 7 are of array type, with one subquestion (choice between "Option AX" and "Option BX", with X=1 or 7).
To do so, I have set-up a question of type "equation" in the group of questions where I have question 7.
Given that I have 8 versions of the questionnaire (8 blocks), I have 16 conditions in my equation.
I want the response to this question to be 1 if the answers are coherent and 0 otherwise.
My problem: When I answer to the questionnaire, I don't see any value in the column corresponding to this coherence question. Can you see an error in the equation?
{if(Block1Qu1[SQ001]=='Option A1' and Block1Qu7[SQ001]=='Option B7', 1,
if(Block2Qu1[SQ001]=='Option A1' and Block2Qu7[SQ001]=='Option B7', 1,
if(Block3Qu1[SQ001]=='Option A1' and Block3Qu7[SQ001]=='Option B7', 1,
if(Block4Qu1[SQ001]=='Option A1' and Block4Qu7[SQ001]=='Option B7', 1,
if(Block5Qu1[SQ001]=='Option A1' and Block5Qu7[SQ001]=='Option B7', 1,
if(Block6Qu1[SQ001]=='Option A1' and Block6Qu7[SQ001]=='Option B7', 1,
if(Block7Qu1[SQ001]=='Option A1' and Block7Qu7[SQ001]=='Option B7', 1,
if(Block8Qu1[SQ001]=='Option A1' and Block8Qu7[SQ001]=='Option B7', 1,
if(Block1Qu1[SQ001]=='Option B1' and Block1Qu7[SQ001]=='Option A7', 1,
if(Block2Qu1[SQ001]=='Option B1' and Block2Qu7[SQ001]=='Option A7', 1,
if(Block3Qu1[SQ001]=='Option B1' and Block3Qu7[SQ001]=='Option A7', 1,
if(Block4Qu1[SQ001]=='Option B1' and Block4Qu7[SQ001]=='Option A7', 1,
if(Block5Qu1[SQ001]=='Option B1' and Block5Qu7[SQ001]=='Option A7', 1,
if(Block6Qu1[SQ001]=='Option B1' and Block6Qu7[SQ001]=='Option A7', 1,
if(Block7Qu1[SQ001]=='Option B1' and Block7Qu7[SQ001]=='Option A7', 1,
if(Block8Qu1[SQ001]=='Option B1' and Block8Qu7[SQ001]=='Option A7', 1, 0
))))))))))))))))}
Many thanks in advance for your help
I need to check whether the answers to Qu1 is coherent with the answer in Qu7. It is coherent if is the opposite (A in Qu1 and B in Qu7 or B in Qu1 and A in Qu7 ).
The questions 1 and 7 are of array type, with one subquestion (choice between "Option AX" and "Option BX", with X=1 or 7).
To do so, I have set-up a question of type "equation" in the group of questions where I have question 7.
Given that I have 8 versions of the questionnaire (8 blocks), I have 16 conditions in my equation.
I want the response to this question to be 1 if the answers are coherent and 0 otherwise.
My problem: When I answer to the questionnaire, I don't see any value in the column corresponding to this coherence question. Can you see an error in the equation?
{if(Block1Qu1[SQ001]=='Option A1' and Block1Qu7[SQ001]=='Option B7', 1,
if(Block2Qu1[SQ001]=='Option A1' and Block2Qu7[SQ001]=='Option B7', 1,
if(Block3Qu1[SQ001]=='Option A1' and Block3Qu7[SQ001]=='Option B7', 1,
if(Block4Qu1[SQ001]=='Option A1' and Block4Qu7[SQ001]=='Option B7', 1,
if(Block5Qu1[SQ001]=='Option A1' and Block5Qu7[SQ001]=='Option B7', 1,
if(Block6Qu1[SQ001]=='Option A1' and Block6Qu7[SQ001]=='Option B7', 1,
if(Block7Qu1[SQ001]=='Option A1' and Block7Qu7[SQ001]=='Option B7', 1,
if(Block8Qu1[SQ001]=='Option A1' and Block8Qu7[SQ001]=='Option B7', 1,
if(Block1Qu1[SQ001]=='Option B1' and Block1Qu7[SQ001]=='Option A7', 1,
if(Block2Qu1[SQ001]=='Option B1' and Block2Qu7[SQ001]=='Option A7', 1,
if(Block3Qu1[SQ001]=='Option B1' and Block3Qu7[SQ001]=='Option A7', 1,
if(Block4Qu1[SQ001]=='Option B1' and Block4Qu7[SQ001]=='Option A7', 1,
if(Block5Qu1[SQ001]=='Option B1' and Block5Qu7[SQ001]=='Option A7', 1,
if(Block6Qu1[SQ001]=='Option B1' and Block6Qu7[SQ001]=='Option A7', 1,
if(Block7Qu1[SQ001]=='Option B1' and Block7Qu7[SQ001]=='Option A7', 1,
if(Block8Qu1[SQ001]=='Option B1' and Block8Qu7[SQ001]=='Option A7', 1, 0
))))))))))))))))}
Many thanks in advance for your help
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13637
- Thank you received: 2491
6 years 5 months ago #160431
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 to test coherence between two answers (array with subquestion)
Hi,
1. error in variable name : Block1Qu1[SQ001] to Block1Qu1_SQ001, see manual.limesurvey.org/Expression_Manager#Qcode_Variable_Naming
2. It's better to use answer code 'Option B1' to "B1" if code is B1
1. error in variable name : Block1Qu1[SQ001] to Block1Qu1_SQ001, see manual.limesurvey.org/Expression_Manager#Qcode_Variable_Naming
2. It's better to use answer code 'Option B1' to "B1" if code is B1
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: lefebvremarianne
The topic has been locked.
- lefebvremarianne
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
6 years 5 months ago #160438
by lefebvremarianne
Replied by lefebvremarianne on topic equation to test coherence between two answers (array with subquestion)
Thanks a lot. Its working!
The topic has been locked.