Why doesn't the count_selected function return an integer?

545
3
05-23-2017 05:41 PM
MikeOnzay
Occasional Contributor III

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. 

count_selected

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.

Tags (2)
0 Kudos
3 Replies
JamesTedrick
Esri Esteemed Contributor

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.

0 Kudos
MikeOnzay
Occasional Contributor III

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?

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Yes, it returns a number; it can be used directly in a calculation of a note or other field.

0 Kudos