Have an idea?

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

Logic of select question

Dear Support,
I have checkbox question"OI"  where these are the  categories:
1- PTV owner
2- PTV intender
3- Ref owner
4- Ref intender
5- WM owner
6- WM intender
7- AC owner
8- AC intender
9- Fan owner
10- Fan intender

 I need to apply any these four conditions and if not terminate:

•    2 owners    For 2 different products if there is no intender
•    1 intender & 2 owners     2 or 3 products
•    3 intenders     For 3 different products
•    2 intenders & 1 owner     2 or 3 products

Please help.

Thanks in advance
asked Jan 23 by Marwa

1 Answer

+1 vote
 
Best answer
Please try this skip logic:

Begin Unverified Perl
my $selectQ = 'SelectQ';
my $owns = 0;
my $intends = 0;
for (my $item = 1; $item <= 10; $item += 2) {
    $owns += GETVALUE($selectQ . '_' . $item);
    $intends += GETVALUE($selectQ . '_' . ($item + 1));
}
if (($owns == 2 && $intends <= 1) || ($owns == 0 && $intends == 3) || ($owns == 1 && $intends == 2)) {
    return 0;
}
return 1;
End Unverified


Line 2 must be updated to reflect the name of the select question.
answered Jan 23 by Zachary Platinum Sawtooth Software, Inc. (129,350 points)
selected Jan 23 by Paul Moon
...