Have an idea?

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

Ranking within a loop

Hi all

I've set up a question within a loop whereby respondents are asked to rank brands according to various attributes.  I need to then get the first ranked brand for two particular attributes.  How do I do that?  I'm on version 9.10.1
asked Apr 11, 2021 by Marion Silver (5,400 points)

1 Answer

0 votes
You can use below statement considering, you need 1st ranked brands of attributes 4 & 7 and ranking question name is Q1 with only one column.

AIE(Q2_c1.4,1)
AIE(Q2_c1.7,1)


Based on the attribute number in parent list of your loop constructed list, you just need to change the number 4, 7 in the perl logic.
answered Apr 12, 2021 by KarthikMahankali Silver (5,050 points)
I'm using the following, but it just doesn't work:

AIE(Q27.11,1)


I know the code itself is fine - I use ranking questions all the time outside loops (AIE(Q32,1) as an example) but for whatever reason it just doesn't set when used in a loop.  I even tried setting the lists WITHIN the loop but that didn't work either.
Try using the below code in which you need to update row constructed list name used in Q27 question in place of A11RowConst and .11 with your respective loop number.

Begin Unverified Perl
my $li=LISTVALUESARRAY("A11RowConst");
my $l=substr($li,1,length($li)-2);
my @ar=split(",",$l);
for(my $a=0;$a<@ar;$a++)
{
    if(VALUE("Q27_".$ar[$a].".11)==1)
    {
    ADD(PARENTLISTNAME(),$ar[$a]);
    }
}
End Unverified
...