Exit from finite Repeat Group with sentinel variable

1. What is the issue? Please be detailed.
I have two repeat groups developed for Odk Collect (xlsform) that request information from household members.

In the first Repeat, the name, sex and age are requested. In the 2nd Repeat extra information is requested for all members added in the 1st repeat. I have created a sentinel variable that tells me if in any variable of the 2nd repeat the interview has been abandoned and exit the 2nd repeat, but when adding the code in calculation:

if(position(..) = 1, 1, indexed-repeat($ {ExitRepeat2}, ${list_membersHogar2}, position(..)-1)),

formsValidate throws me the following error message

Why does it give me that error?
Is there another way to access a previous data within the same 2nd repeat?

I add part of the form:
Exit from repeat.xlsx (12.4 KB)

Inside the excel file, I have put a red background where the error is

Thanks in advance

2. What steps can we take to reproduce this issue?

3. What have you tried to fix the issue?

4. Upload any test forms or screenshots below.

Hi @bdra2778, you should fix some errors I have found. I am not sure if there are more or if there were root causes:

Row 29: Extra parentheses
Row 2 CH.1 does not exist
Row 21 CH.1 does not exist Exit_1 does not exist

Hola @Alexander_Torrado

Actually, the file that I uploaded was only a fragment of my form, I upload the corrected fragment again but I still have the same problem that I has already been mentioned (the calculation of a previous value within the repeat2).

The problem is with this code in repeat2 when I try to get the previous valor of ${ExitRepeat2}:

if(position(..) = 1, 1, indexed-repeat(${ExitRepeat2}, ${list_miembrosHogar2}, position(..)-1))

In fact I already tried with:

if(position(..) = 1, 1, ${last-saved#ExitRepeat2})

and it doesn't work either.

Does anyone know of another way to get that value?

Cheers

Exit from repeat.xlsx (12.1 KB)

Hello, can someone help me with this problem please?
I need to solve this problem.

Regards

Hello

I have reviewed the following link: https://docs.getodk.org/form-logic/#repeating-as-long-as-a-condition-is-met

and it could be what I am looking for but I cannot apply it to my form. Could someone give me a hand. I share a fragment of the form that I have made but without positive results

Exit from repeat - notworking.xlsx (12.7 KB)