I have Q1 with 27 brands
Q3 have following conditions
1. Q3 IS A SERIES OF QUESTIONS, ONE QUESTION PER BRAND –
2. IF 7 OR FEWER BRANDS SELECTED IN Q1, SHOW EACH OF THEM IN Q3 FOLLOW-UPS
3. IF >7 BRANDS SELECTED, USE SOME SORT OF LEAST FILL QUOTA (I.E., SEND RESPONDENT TO THE BRANDS WITH THE LOWEST QUOTA COUNT FIRST). IF QUOTAS ARE EQUAL, RANDOMLY CHOOSE
4. SHOW A MAXIMUM OF 7 IN Q3 FOLLOW-UPS
I have created 27 quotas with the name of Q3QP1 to Q3QP27
and added 2 constructed list
List 1
-------
AIC(Q1)
List 2
-------
Begin Unverified Perl
if (LISTLENGTH("Q3List")<=7)
{ADD("Q3List")}
else
{
my $i=0;
my $small=0;
my $pos1=0;
my $pos2=0;
my $pos3=0;
my $pos4=0;
my $pos5=0;
my $pos6=0;
my $pos7=0;
$small=QUOTACELLCOMPLETES("Q3QP1", 1);
for($i=1;$i<=27;$i++)
{
if((QUOTACELLCOMPLETES("Q3QP" . $i, 1) <= $small) && LISTHASPARENTMEMBER("Q3List", $i)==1)
{
$pos1=$i;
$small=QUOTACELLCOMPLETES("Q3QP" . $i, 1);
}
}
$small=QUOTACELLCOMPLETES("Q3QP1", 1);
for($i=1;$i<=27;$i++)
{
if($pos1!=$i)
{
if((QUOTACELLCOMPLETES("Q3QP" . $i, 1) <= $small) && LISTHASPARENTMEMBER("Q3List", $i)==1)
{
$pos2=$i;
$small=QUOTACELLCOMPLETES("Q3QP" . $i, 1);
}
}
}
$small=QUOTACELLCOMPLETES("Q3QP1", 1);
for($i=1;$i<=27;$i++)
{
if($pos1!=$i && $pos2!=$i)
{
if((QUOTACELLCOMPLETES("Q3QP" . $i, 1) <= $small) && LISTHASPARENTMEMBER("Q3List", $i)==1)
{
$pos3=$i;
$small=QUOTACELLCOMPLETES("Q3QP" . $i, 1);
}
}
}
$small=QUOTACELLCOMPLETES("Q3QP1", 1);
for($i=1;$i<=27;$i++)
{
if($pos1!=$i && $pos2!=$i && $pos3!=$i)
{
if((QUOTACELLCOMPLETES("Q3QP" . $i, 1) <= $small) && LISTHASPARENTMEMBER("Q3List", $i)==1)
{
$pos4=$i;
$small=QUOTACELLCOMPLETES("Q3QP" . $i, 1);
}
}
}
$small=QUOTACELLCOMPLETES("Q3QP1", 1);
for($i=1;$i<=27;$i++)
{
if($pos1!=$i && $pos2!=$i && $pos3!=$i && $pos4!=$i)
{
if((QUOTACELLCOMPLETES("Q3QP" . $i, 1) <= $small) && LISTHASPARENTMEMBER("Q3List", $i)==1)
{
$pos5=$i;
$small=QUOTACELLCOMPLETES("Q3QP" . $i, 1);
}
}
}
$small=QUOTACELLCOMPLETES("Q3QP1", 1);
for($i=1;$i<=27;$i++)
{
if($pos1!=$i && $pos2!=$i && $pos3!=$i && $pos4!=$i && $pos5!=$i)
{
if((QUOTACELLCOMPLETES("Q3QP" . $i, 1) <= $small) && LISTHASPARENTMEMBER("Q3List", $i)==1)
{
$pos6=$i;
$small=QUOTACELLCOMPLETES("Q3QP" . $i, 1);
}
}
}
$small=QUOTACELLCOMPLETES("Q3QP1", 1);
for($i=1;$i<=27;$i++)
{
if($pos1!=$i && $pos2!=$i && $pos3!=$i && $pos4!=$i && $pos5!=$i && $pos6!=$i)
{
if((QUOTACELLCOMPLETES("Q3QP" . $i, 1) <= $small) && LISTHASPARENTMEMBER("Q3List", $i)==1)
{
$pos7=$i;
$small=QUOTACELLCOMPLETES("Q3QP" . $i, 1);
}
}
}
ADD("Q3List", $pos1);
ADD("Q3List", $pos2);
ADD("Q3List", $pos3);
ADD("Q3List", $pos4);
ADD("Q3List", $pos5);
ADD("Q3List", $pos6);
ADD("Q3List", $pos7);
}
End Unverified
but it doesn't work, it shows only 2 or 3 brands if I selected more than 7 brands in Q1.
Please help me to achieve this logic.
Thanks