AnsweredAssumed Answered

Count how many times a choice is used.

Question asked by MarkCainNZ on Mar 28, 2019
Latest reply on Mar 28, 2019 by MarkCainNZ


I'm trying to count the number of times a choice has been selected across many select_one questions.

as an example

The count works when only one instance is chosen, but fails to add values.


I realise this is due to the use of the 'if' statement as a control.


However if i use

if(selected(${firstchoice,'a') and selected(${secondchoice},'a'),2,if(selected(${firstchoice},'a') or selected(${secondchoice},'a'),1,0) it does work. (used for option 'c' above)


This solution is okay if there are only 2 options, however I want to count the number across 23 questions and the if statement would have 100's of permutations to enter.


There must be a better way.


I have tried using hidden fields as variable to hold the count, which doesn't work, (as in the first note field above), but i cant get the addition to work.


I have tried using countif but that is not a recognised function, and count(selected()) only works across multiple selects which is not an option for my audit


Any ideas?