Hi,
I am looking for a way to pull data from an earlier repeat section following conditions that I would determine. For example, I would like to pull the position index of a certain repeat entry if it fills those conditions.
Something like:
x = repeat_index where ((field_name_1 == 123) AND (field_name_2 == ''cheese''))
I know this is not the way it would be implemented in Survey 123. It's just to give a broad idea of what I need.
Thanks in advance!
I believe you are looking for indexed repeats.
Scroll down and look for "Return the index of a repeat record" and "Use values from indexed repeats" https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformrepeats.htm
I get that you are refering to this request structure :
indexed-repeat(${question}, ${repeat_name}, index)
Now, I do have the <question> and the <repeat_name>. However, I would like to obtain the <index> based on conditions in the repeat table. Let's assume the following repeat table :
index | food | amount | name |
0 | steak | 6 | paul |
1 | tofu | 24 | alice |
2 | cheese | 4 | eric |
3 | brocoli | 56 | pamela |
4 | tofu | 78 | amy |
Would it be possible to pull the index value where 'food' = 'tofu' and 'amount' = 78?
Is there a risk of multiple items in this repeat matching your conditions?
If there is no risk of duplicate items, you could simply set up a calculate inside the repeat: if(selected(${food},'tofu') and ${amount}='78', position(..),'')
This will only contain your index when the conditions are met. You can then pull data using that index. If there is a risk of multiple items matching the conditions, you will need something different.