- Posts: 17
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Four ways to count:
A1Q1 is the question code. And example with only 5 subquestions.
1. The longest, but easiest to understand:
{sum(if(A1Q1_SQ001==1,1,0),if(A1Q1_SQ002==1,1,0),if(A1Q1_SQ003==1,1,0),if(A1Q1_SQ004==1,1,0),if(A1Q1_SQ005==1,1,0))}
You sum up:
If the 1st subquestion is equal 1, you sum 1, else 0
If the 2nd subquestion is equal 1, you sum 1, else 0
...
2. The use of boolean expression
{sum(A1Q1_SQ001==1,A1Q1_SQ002==1,A1Q1_SQ003==1,A1Q1_SQ004==1,A1Q1_SQ005==1)}
Again you sum up.
And you know that a boolean comparison is equal 1, if true, 0, if false.
So again you sum up the five subquestion with each comparison has a value of 1 or 0.
3. Use of the function countifop (Count the number of answered questions in the list which pass the criteria (arg op value))
{countifop('==',1,A1Q1_SQ001,A1Q1_SQ002,A1Q1_SQ003,A1Q1_SQ004,A1Q1_SQ005)}
You see the first two parameters, which say "equal" and "1".
Then the five subquestions.
4. Use of countifop and "that"
{countifop('==',1,that.A1Q1.NAOK)}
You count the appearance of "=1" in the whole question A1Q1.