Default to next value in a choice list between repeats

368
1
12-20-2018 08:41 AM
BrandonLegere
New Contributor

I currently have a survey where users are collecting measurements along a linear asset, and must do so at predefined 200 foot increments.  They are currently identifying this increment within a select one question that contains scaled numeric values along with some non-numeric choices like "Start of Project".  Example Values below:

Start_Station
200
400
600
800
1000
1200

Individual measurements are collected within a repeat, below some project header information.  The functionality that I really need, is to present a user with a default value that is based upon the last measurement collected.  Example: If the last collected measurement was 200, then the next iteration within the repeat would default to the next option within the pick list (400).

I've attempted to accomplish this by converting all the values within the pick list to a number using the pulldata function and a media table, and then calculating a MAX field within the header that I could key off of.  I've been successful getting this combination of fields to provide the suggested value, however am receiving the following error when I attempt to use it in the calculation for the field I hoped to pre-populate.

>> Something Broke the parser. See above for hint.

Dependency cycles amongst the xpath expressions in relevant/calculate

Results: Invalid

I believe that I've created an infinite loop here, but don't see an available alternative.  Does Survey123 otherwise support suggesting/defaulting to the next value in a choice list within a repeat?

0 Kudos
1 Reply
by Anonymous User
Not applicable

Hi Brandon,

Yes, sounds like you have created a calculation cycle which throws an error by referencing the same question in a loop. Can you share you xslx form so can take a closer look?

I am thinking it should be possible to do what you are after, either using once() or count() or max() (or a combination of all 3) and then pulldata() to get the next value, you may just need to use some null field types in between the store temporary values to then calculate off. It will be easier to test once I can see your form.

Phil.

0 Kudos