Counting number of answers selected from a multiple choices question with condition

Hej all,

I currently want to build a logic where the questionnaire first asks a farmer for the crops he*she cultivated in a season. Then based on the selected amount of answers the farmer is asked for each crop a number of questions on plot size, yields, input cost etc. separately for each crop. I know that I can do this with counting the selection and then generate individual rosters on that basis.
But how can I count the selected divided in two groups?
My use case is that the entire list of crops contains field crops and “crops”/fruits on trees. For the field and tree crops the questions in the roster are different. How do I condition the count-select() command appropriately?

Thank you for any leads,
Daniel

Hi @Dano,

Why don’t you use 2 different questions for field crops and crops/fruits on trees?

Could you share the related part of your form, incl. the (grouped) choices, please.

In addition to hakan_cetinkaya:

  • You could use the total of all count-selected() for a common loop and group inside and filter by relevant depending on the selected group (which can be detected e.g. by combining selected() in a calculation).
  • You could add a repeat group stepping through all selected choices (with selected_at(…, position(…)-1) and calculating the total number (frequency) for each group.
1 Like