- Posts: 13
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
EM to sum question type array
- outofgamut
- Topic Author
- Offline
- New Member
I am trying to implement a simple questionnaire score.
9 questions with 4 answer each: (never (0), some (1), often (2), always (3)). I would like EM to assign the numbers in parenthesis to those answer and allow me to do sums.
I have used array as the radio buttons automatically only allow exactly one answer per row but I can't make LimeSurvey assign values to my columns.
Is there a way to easily achieve what I am after?
- holch
- Offline
- LimeSurvey Community Team
- Posts: 11758
- Thank you received: 2753
Later you can write a simple expression that sums the responses to each subquestion.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
- outofgamut
- Topic Author
- Offline
- New Member
- Posts: 13
- Thank you received: 0
I looked at every part of the manual before I posted but didn't get far. I initially had tried assessment values but EM did not incorporate them when I used sum().
I'd love to use your second option - how do I assign values to answer options that EM can evaluate?
- holch
- Offline
- LimeSurvey Community Team
- Posts: 11758
- Thank you received: 2753
I show you both the option I mentioned.
1. Using the assessment values (Assessment values 0, 1, 2, 3)
2. Using the answer codes (To show the difference I used the codes 1, 2, 3, 4)
I used an array question for this, but this can be done with seperate questions as well.
To access the value of each subquesiton, you need to use
questioncode_subquestioncode.value
In my case, as I call the question G1Q1 and have 3 subquestions, these are the codes you need to use:
G1Q1_1.value G1Q1_2.value G1Q1_3.value
Without .value at the end you will access the response code.
Have a look at the attached survey and play around and see the effects.
You could of course also give the 0, 1, 2, 3 directly to the response code and only sum those.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
- outofgamut
- Topic Author
- Offline
- New Member
- Posts: 13
- Thank you received: 0
I also need to assess the number of ticks in columns. I am evaluating the array's column like
{sum(that.myarray.sq_2.NAOK)}
Am I mixing something up?
- holch
- Offline
- LimeSurvey Community Team
- Posts: 11758
- Thank you received: 2753
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
- outofgamut
- Topic Author
- Offline
- New Member
- Posts: 13
- Thank you received: 0
You can also use these to get row and column totals. Say you have a array of numbers with rows A-E and columns 1-5.
What is the grand total? {sum(self.NAOK)}
What is the total of row B? {sum(self.sq_B.NAOK)}
What is the total of column 3? {sum(self.sq_3.NAOK)}
The 'that' variable is like the 'self' variable, but lets you refer to other questions. Its syntax is:
that.qname
that.qname.suffix
that.qname.sub-selector
that.qname.sub-selector.suffix
qname is the question name without any sub-question extensions. So, say you create a question 'q1', that is its qname
Examples:
Has any part of question q1 been answered? {count(that.q1.NAOK)>0}
What is the assessment score for q2? {sum(that.q2.NAOK)}
What is the grand total of q3? {sum(that.q3.NAOK)}
What is the total of row C in q4? {sum(that.q4.sq_C.NAOK)}
What is the total of column 2 in q4? {sum(that.q4.sq_2.NAOK)}
The 'self' and 'that' variables can be used in any relevance, validation, or tailoring.
The one caveat is that when you use the Show Logic File feature, it will show you the expanded value of 'self' and 'that'. This lets you see the actual equation that will be generated so that you (and Expression Manager) can validate that the variables exist. This may seem confusing since you may see quite lenghty equations. However, if you edit the question, you will see the original equation using 'self' and/or 'that'