- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Equation to translate certain radio list responses into a summed score
- jkaufman
- Topic Author
- Offline
- New Member
Less
More
8 years 4 months ago #129124
by jkaufman
Equation to translate certain radio list responses into a summed score was created by jkaufman
My survey contains a question group of 100 similar radio list questions. I am looking to add an equation question that reads the responses to 10 of these questions and sums the values of their answer option codes.
For example, assuming the radio list questions take the form:
… if survey participant answers "Disagree" for all question codes a1 through a10, I would like to write 20 to the database (2 ("disagree") x 10 (number of questions) = 20). The answers are ordered consistently, so a solution that uses the answer index instead of the answer option code is acceptable. I'm really looking to avoid using JavaScript.
Thank you!
For example, assuming the radio list questions take the form:
Code:
Q: "What do you think of this statement?" A: 1. "Completely disagree" 2. "Disagree" 3. "Somewhat disagree" 4. "Neither agree nor disagree" 5. "Somewhat agree" 6. "Agree" 7. "Completely agree"
… if survey participant answers "Disagree" for all question codes a1 through a10, I would like to write 20 to the database (2 ("disagree") x 10 (number of questions) = 20). The answers are ordered consistently, so a solution that uses the answer index instead of the answer option code is acceptable. I'm really looking to avoid using JavaScript.
Thank you!
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
8 years 4 months ago #129126
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 translate certain radio list responses into a summed score
Hi,
Withouts assessments :
{sum(str_replace("A","",Q1.NAOK),str_replace("A","",Q2.NAOK),str_replace("A","",Q3.NAOK), ...)}
With assessments:
{sum(Q1.valueNAOK,Q2.valueNAOK,Q3.value,)}
Or {ASSESSMENT_CURRENT_TOTAL} If you have only this question type.
manual.limesurvey.org/Assessments#Assessment_placeholders
Denis
Withouts assessments :
{sum(str_replace("A","",Q1.NAOK),str_replace("A","",Q2.NAOK),str_replace("A","",Q3.NAOK), ...)}
With assessments:
{sum(Q1.valueNAOK,Q2.valueNAOK,Q3.value,)}
Or {ASSESSMENT_CURRENT_TOTAL} If you have only this question type.
manual.limesurvey.org/Assessments#Assessment_placeholders
Denis
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: jkaufman
The topic has been locked.
- jkaufman
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
8 years 4 months ago #129131
by jkaufman
Replied by jkaufman on topic Equation to translate certain radio list responses into a summed score
That worked exactly as hoped and is very clear. Thank you so much! In case anyone else runs into a similar problem, there is some relevant discussion of sum() and NAOK in
Expression Management HowTos
.
The topic has been locked.