Indexed-repeat - Pull Value From Last Repeat

1. What is the problem? Be very detailed.
I've got a repeat group where the respondent will continue changing the bid amount until they say yes to another question inside the repeat group. Thanks to the repeat_count calculation the repeats stop when a 'yes' is answered to a confirm question.

Outside the repeat, I need to create a variable that contains the final bid. This would be the ${bid} from the repeat_group where confirm=1. At the moment the indexed-repeat(${bid}, ${repeat_group}, position(../..)) returns the value of the first repeat even when I have 2-3 repeats.

2. What app or server are you using and on what device and operating system? Include version numbers.
SurveyCTO - using their form designer to test.

3. What you have you tried to fix the problem?
I could likely hard code index-repeats for both ${bid} and ${confirm} for an estimated number of positions I think will be the maximum of the repeat (say 10) and from there use logic statement to get the correct bid. However, it would be nice to see if a simpler method exists.

4. What steps can we take to reproduce the problem?

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.
Attached is a section of the survey with the problem. indexed-repeat-nested.xlsx (4.9 KB)

Hello @Dnferris,

The form you attached is kinda different to the issue described.

Anyhow, here is what you need to get the result:

  • Create a calculate variable inside the repeat and call it temp_final_bid with calculation as if(${confirm} = 1, ${bid}, 0) I used =1 assuming your yesno question uses 1 or 0. This variable will keep a copy of the bid where confirmation was provided
  • Outside the repeat, create another calculate or integer variable and call it final_bid with calculation like max(${temp_final_bid) or sum(${temp_final_bid} these should work all the same as you only feed value in the temp_final_bid once in the entire repeat

This should make it, no need for indexing of repeats

Jules R

thanks for the awesome information.