# More details on certain answers without repeating them

**URL:** <https://forum.getodk.org/t/more-details-on-certain-answers-without-repeating-them/47393>\
**Category:** Support\
**Tags:** odk-xlsform\
**Created:** [June 9, 2024, 3:26pm UTC](https://forum.getodk.org/t/more-details-on-certain-answers-without-repeating-them/47393 "2024-06-09T15:26:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebtux](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/sebtux/32/14658_2.png) [@sebtux](https://forum.getodk.org/u/sebtux)\
**Post date:** [June 9, 2024, 3:26pm UTC](https://forum.getodk.org/t/more-details-on-certain-answers-without-repeating-them/47393/1 "2024-06-09T15:26:53Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![aankrah](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/aankrah/32/12857_2.png) [@aankrah](https://forum.getodk.org/u/aankrah)\
**Post date:** [June 11, 2024, 8:34am UTC](https://forum.getodk.org/t/more-details-on-certain-answers-without-repeating-them/47393/2 "2024-06-11T08:34:27Z")

</div>

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()`?

---

<div class="post-metadata">

**Author:** ![rfvieira](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/rfvieira/32/16852_2.png) [@rfvieira](https://forum.getodk.org/u/rfvieira)\
**Post date:** [June 12, 2024, 2:18pm UTC](https://forum.getodk.org/t/more-details-on-certain-answers-without-repeating-them/47393/3 "2024-06-12T14:18:32Z")

</div>

Hello @sebtux and @aankrah ,

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

The choice list is like this:  
 ![image](https://getodk.b-cdn.net/uploads/default/original/3X/8/4/8400540cea9495926c2c42a5655c81a42357c699.png)

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](https://forum.getodk.org/uploads/short-url/pO6wCGQ1f7e3cfEH0ztxxj9fBIK.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,

---

<div class="post-metadata">

**Author:** ![sebtux](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/sebtux/32/14658_2.png) [@sebtux](https://forum.getodk.org/u/sebtux)\
**Post date:** [June 13, 2024, 1:00pm UTC](https://forum.getodk.org/t/more-details-on-certain-answers-without-repeating-them/47393/4 "2024-06-13T13:00:26Z")

</div>

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](https://getodk.b-cdn.net/uploads/default/original/3X/8/6/861f7db5aa2b75fb17d37660692f7b0e5c08c076.png)  
Here we ask surface sowed.

 ![2024-06-13 09_44_23-RHI24-FormEncuesta-Vicky.xls Modo de compatibilidad - Excel](https://getodk.b-cdn.net/uploads/default/original/3X/1/4/1473a7a12322a71a350c3b5dabca3626f04a2b55.png)  
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

---

<div class="post-metadata">

**Author:** ![jules\_rugwiro](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/jules_rugwiro/32/1738_2.png) [@jules\_rugwiro](https://forum.getodk.org/u/jules_rugwiro)\
**Post date:** [June 13, 2024, 7:24pm UTC](https://forum.getodk.org/t/more-details-on-certain-answers-without-repeating-them/47393/5 "2024-06-13T19:24:42Z")

</div>

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](https://forum.getodk.org/uploads/short-url/gp6SeyyNOUew1QpoHf1cryzyuEp.xlsx) form that expands on suggestions from @rfvieira and @aankrah

Hoping this helps,

Jules R

 ![image](https://getodk.b-cdn.net/uploads/default/original/3X/2/f/2f9f51f52c9bbcf9df24b9954a98a17d200a585b.png) | ![image](https://getodk.b-cdn.net/uploads/default/original/3X/d/e/de46975b81aa093d6be64a552fa5c371dd757721.png)

---

<div class="post-metadata">

**Author:** ![sebtux](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/sebtux/32/14658_2.png) [@sebtux](https://forum.getodk.org/u/sebtux)\
**Post date:** [June 17, 2024, 6:18pm UTC](https://forum.getodk.org/t/more-details-on-certain-answers-without-repeating-them/47393/6 "2024-06-17T18:18:30Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![sebtux](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/sebtux/32/14658_2.png) [@sebtux](https://forum.getodk.org/u/sebtux)\
**Post date:** [June 19, 2024, 12:26am UTC](https://forum.getodk.org/t/more-details-on-certain-answers-without-repeating-them/47393/8 "2024-06-19T00:26:35Z")

</div>

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