Have an idea?

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

How will I do this if I have 2 questions

The client is asking me to select the highest brand acres amongst two questions.  I tried using the syntax above referencing the 2 questions.

AddSorted (Q2_c1,0)
AddSorted (Q4_c1,0)


But the second line of syntax was ignored.

How would I do this with 2 questions?

Thank you
asked Jan 31, 2020 by anonymous
Two thoughts.

First, constructed lists can only add items from their parent list.  So Q2 and Q4's row lists need to be the same list or constructed lists with the same parent.  What many users do in this situation is create a "master list" with all their Q2 and Q4 items, then create constructed lists that split that list into the Q2-only list and Q4-only list, and then use one final constructed list to bring it all together.

Second, the two AddSorted instructions will work independently of each other.  All Q2 items will be added in order, then all Q4 items with be added in order.  Even if a Q4 item has a higher value than a Q2 item, it will still show up later in the list.  If you want both questions' items sorted into one pot, we would need some more complex list instructions.
Hi Zach,

Yes the parent list is the same in Q2 and Q4

Yes, I want both questions items sorted into one pot.  How would I do that?

Thank you
This constructed list is as far as I've been able to get so far, but something about it isn't quite right yet.

Begin Unverified Perl
my $scores;

my $plist = 'list1';
addScores('Q2', 1, 4);
addScores('Q4', 5, 8);

foreach my $score (sort {$b <=> $a} keys %{$scores}) {
    my @items = @{$scores->{$score}};
    foreach my $item (@items) {
        ADD($plist, $item);
    }
}

sub addScores {
    my ($question, $firstItem, $lastItem) = @_;
    for (my $item = $firstItem; $item <= $lastItem; $item++) {
        my $score = GETVALUE($question . '_c1_' . $item);
        if (!exists $scores->{$score}) {
            my @empty = ();
            $scores->{$score} = \@empty;
        }
        push(@{$scores->{$score}}, $item);
    }
}
End Unverified


Shot in the dark, but are the minimum and maximum values that respondents might put into these grid questions relatively close to each other?

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...