I was using count_selected for the first time. Help states "Returns the number of selected answers. Used for select_multiple questions". I expected it to return an integer but it returned the number as text.
I wanted to total the number of answers from three different select_multiple questions.
For each question I chose 1 answer and the note shows:
111
It did a concatenation instead of an addition
My workaround was to use the int function
int(${Repair_type_score_3}) + int(${Repair_type_score_2}) + int(${Repair_type_score_1})
Answer: 3
Ideally I would like to see the function return an actual number instead of a text number. In the meantime the Help could be updated to indicate this difference.
Hi Mike,
The issue is that the calculate question stores a text (string) value by default. To set them to store integers, you need to add a column called
bind::type
and set the values for the calculate columns to integer.
Hi James,
Thanks for the quick reply and the reminder of how calculate stores values. Does this mean that count_selected really does return a number?
Yes, it returns a number; it can be used directly in a calculation of a note or other field.