Hi,
Background info: I am creating a survey for people to go out and test different materials at different locations. The user may need to conduct an unlimited number of tests so I have contained everything in a repeat. On the first repeat, i.e. position(..) = 1, the user is asked to input their location. The question is a text field and their response would be something like 'Road 1' or 'Stormwater Line'. Call this ${location_initial}
On the second repeat they are presented with a select_one question asking them if they have changed location. If they select 'Yes' then a new question appears asking them to input their new location, and if they select 'No' then the initial location is retained in a field in the background.
Calculation for background location field, called ${location_a}:
if ( position(..) = 1, ${location_initial}, if ( ${yesno_newlocation} = 'Yes', ${new_location}, ${location_previous}) )
The calculation for ${location_previous} is:
indexed-repeat(${location_a},${ndm_bs_repeater},${rp_num_bs}-1)
What these calculation's aim to do is check that if the user selects 'No' to being in a new location, then the location of the previous repeat is called in. It causes a dependency cycle though, I guess because I am referencing ${location_a} in the ${location_previous} calculation.
A short sighted way around this would be to change the calculation for ${location_previous} to:
indexed-repeat(${new_location},${ndm_bs_repeater},${rp_num_bs}-1)
The issue with this is that if a person tests at one location for the first repeat, then changes on the second but doesnt change for the third, fourth and fifth... the ${new_location} field doesn't have anthing to pull from after the third repeat because they kept answering 'No' to the 'Have you changed location' question.
Any help would be much appreciated! I have several fields to apply this logic to..... eek