float valueSum(string Question)
float valueSum(string Question, string|array Items)
float valueSum(array Variables)
Calculates the sum of answer codes for all items of a question (e.g. a scale), for selected items or for a list of variables.
array(2,4,6)
[2,4,6]
'1-3,5,7
'['AB01_01', 'AB01_02', 'BB01', 'BC01']
Note: The function valueSum()
can only read regular variables from questions and items. The dwell time (“TIME001”, “TIME002”, …) cannot be read by means of valueSum()
. Please use the function caseTime() and the operator for addition (+
) for this.
Calculate sum over all responses in scale AB01.
$sum = valueSum('AB01');
Sum over items 2, 4, 6, and 8 of the AB01 scale.
$sum = valueSum('AB01', [2,4,6,8]);
Sum over the first 4 items of the AB01 scale.
$sum = valueSum('AB01', '1-4');
Sum over the responses in variables AB01_01, AB01_03, and BB01_02 (as array in square brackets).
$sum = valueSum(['AB01_01','AB01_03','BB01_02']);
The same command again a little more clearly
$sum = valueSum([ 'AB01_01', 'AB01_03', 'BB01_02' ]);