Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

How to loop the variables with the highest numeric value?

Hi - I have a question about looping. In short, I need to show the top two answer values (numeric) from one question as the column headers in a grid question. The numeric values answered will vary greatly so I cannot merely write logic saying that if Option A>70 loop it into Q2. Rather, I need to write logic that says if Option A> all options and Option C>all options (-Option A) loop them both into Q2.  Please see below for the questionnaire and logic set up.

Q1 Please apportion 100 points to the below marketing partners:
Option A
Option B
Option C
Etc.

Based on Q1, loop the options with the top two values into the answer choices in Q2.

Q2 On a scale of 1-7, how well do the below two marketing partners perform on the following features?
[Grid; rows=features; columns=top 2 competitors looping in from Q1]

Any insight on how best to go about this?
asked Nov 4 by anonymous

1 Answer

0 votes
This can be done with constructed lists.  In the List Manager, create a new constructed list and set its parent to the list being used in Q1.  Then give the constructed list these instructions:

AddSorted(Q1)
SetListLength(2)


If you rename the first question, be sure to update "Q1," of course.

You may want to test this code and verify that it handles tiebreaking in an acceptable way.  If you need ties handled in a different way, it may be possible with some adjustments to the code.
answered Nov 4 by Zachary Platinum Sawtooth Software, Inc. (129,350 points)
I believe that tied scores are randomised automatically by this feature.

I tested this in the past. That was the behaviour and I also confirmed this with Mike Lodder (ex-Sawtooth Software employee).

To be honest, that's a nice inbuilt feature for this function.
Good catch, Paul.  I only ran a quick test with it that made it seem not randomized, but that must have just been a coincidence of too small a sample size.
...