More details on certain answers without repeating them

Hi,

I need to survey a couple of variables about sowing and then ask more questions about garlic.

I created 2 repeating groups:

The first one asks for the varieties/species and the sowed surface
The second one must ask more specific details only on garlic varieties registered in the first one. To achieve this I used an indexed-repeat as explained in https://docs.getodk.org/form-operators-functions/#indexed-repeat to relate both groups and avoid repeating answers and empty ones (in the 2nd repeating group)

What I can't find out is how to filter everything except garlic varieties. I tried filters and starts-with() function in the relevant column without success.

Which approach would you suggest me? TIA,

--
seb

Hi @sebtux,

Hard to say what might work in your instance without the structure of your repeats. Have you tried using contains() instead of starts-with()?

Hello @sebtux and @aankrah ,

I tried to create some context to better explain my thoughts, sorry in advance for any mistake :slight_smile:

The choice list is like this:
image

Then I can use a relevant clause not(substr(${SelectedVariety},0,6)='garlic') but in order to do that I need to calculate this ${SelectedVariety} as we are looping on every selected option.

The calculation is selected-at(string(${Varieties}),position(..)-1) inside the repeat structure.

Here is an example:
sowing-repeat.xlsx (13.0 KB)

Hope that helps!

Please share your thoughts about it, am I missing anything? Is there a better way to solve this?

Cheers,

Hi,

It's a very good example!

Is it possible to hide/show the whole RptSowingDetails repeat group (Sowing details) instead of just some questions? Where would you insert the calculate fields?

Part of the draft version of the survey.

2024-06-13 09_44_02-RHI24-FormEncuesta-Vicky.xls  Modo de compatibilidad - Excel
Here we ask surface sowed.


There are two sections like this one only relevant to 4 garlic varieties.

What I'm trying to do is iterate in section 5. the number of garlic varieties filled in section 3.10

TIA,

--
seb

Hello @sebtux,

What you want are mirrored repeats. That is, in theory, all repeats have equal number of iterations (repeat_count), though, the user would only see relevant follow-up. To achieve this:

  • Create a template array (space delimited text) that holds the varieties of interest. ${garliVar} with calculation ("garlic_bogatyr garlic_brown_tempest garlic_calabrian_red garlic_chesnok_red garlic_french_pink")
  • in each follow-up repeat, add a group that will only show in the current repeat value of selected variety is a member of the ${garliVar} array using selected(${garlicVar}, ${garSelectedVariety}) as relevant

The are several benefits with this method: (1) ease of coding, no need to track indices of each repeat, (2) any change in main repeat is automatically reflected in follow-up repeats

See the sowing-repeat.xlsx form that expands on suggestions from @rfvieira and @aankrah

Hoping this helps,

Jules R

|

1 Like

Great! It works perfectly thank you Jules!

Do you think it's possible to show only the selected garlic variety and hide the unselected ones when filling the sowing details? Or maybe hide the question as it's read only...

Sorry about that, the column "appearance" had a typo