I’m trying to create a select_multiple list like this post:
The expected behavior is that the options in num_partida_fin is the list of num_partida_inicio inputs. The problem is that if tipo_registro is different from ‘inicio_partida’ (i.e: paro) a new repeat iteration is created with no num_partida_inicio so the list in num_partida_fin has empty options and some non-empty options are not shown because cant_part is not incremented.
I think the best approach would be filtering out the empty options but I can’t find the way to do that.
Is there any way to avoid the empty options so the num_partida_fin show the correct options?
@jventayol, did you mean the Start Game should not display in the next record if that is already been selected in the first record as shown in the image below?
Hello @Kal_Lam,
Not quite. Sorry for not being clear enough.
This is a screenshot of the expected behavior where the options in num_partida_fin are all numeric and they all are the num_partida_inicio different inputs :
That’s because indexed-repeat(${num_partida_inicio},${registro}, 2) calculation (partida2 question) is an empty record.
I can think about 2 possible solutions (theoretically):
Filtering out the empty fields - This will lead in deleting current filter=${cant_part} as it would be redundant
Dinamically feed the position in indexed_repeat by (somehow) storing the position(..) only when inicio_partida is selected in tipo_registro. It should be stored every time inicio_partida is selected (should be in different variables)
Problem is I don’t know how to implement either solution or if those solutions are doable in Kobotoolbox.
Hi @Kal_Lam, just following up on this issue. I’m still trying to find a clean way to exclude empty values generated by indexed-repeat() from the select_multiple choices. Has anyone found a practical approach for filtering blank options or dynamically building the list without empty entries? Any suggestions or workarounds would be greatly appreciated. Thanks!
Sure. Let’s say I have three records in my repeat:
First one is Inicio Partida with the value 1
Second one is Paro, so num_partida_inicio is empty
Third one is Inicio Partida with the value 2
Later, I’m using indexed-repeat() to build the options for another question. The problem is that it returns 1, blank, 2, so the user sees an empty option in the list.
What I’m really trying to figure out is whether there’s a way to ignore those empty values before they appear as choices. I wasn’t sure if there’s a function or a common workaround for this, or if I need to approach it differently.
Hope that explains it a bit better. Thanks for taking a look!
You can exclude any ‘choices’ obtained from a repeat loop source for your followup select question by using a choice_filter. In your example, presumably you want to filter out any choices where num_partida_inicio is empty.
Have a look at the following form, which filters the followup select_one when one of the fields - occupation - inside the repeat is blank, so that only choices where an occupation has been given are included: