Have an idea?

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

Complex filters (logic check)

Dears,

I need to do a logic check between many questions,

I have 10 single questions with the same brand list with 4 options (S261,S262,S263,S264,S265,S266,S267,S268,S269,S270 ) and another single question called segment with 2 options

If we choose codes 1 or 2 in questions (S261,S262,S263) we need to appear only first option in Segment question.

If we choose codes 1 or 2 in questions (S264,S265,S266,S267,S268,S269,S270) we need to appear only second option in Segment question.

Thanks
asked Jan 25 by ossamaKhattab (140 points)

1 Answer

0 votes
At your segment question, you can use the following constructed list ...

This will use the parent list SegmentList which has 1=Segment 1 and 2=Segment 2.
Begin Unverified Perl 
  
 if ((VALUE("S261")==1)||(VALUE("S261")==2)||(VALUE("S262")==1)||(VALUE("S262")==2)||(VALUE("S263")==1)||(VALUE("S263")==2))
  {  
   ADD("SegmentList",1);
  }

 elsif ((VALUE("S264")==1)||(VALUE("S264")==2)||(VALUE("S265")==1)||(VALUE("S265")==2)||(VALUE("S266")==1)||(VALUE("S266")==2)||(VALUE("S267")==1)||(VALUE("S267")==2)||(VALUE("S268")==1)||(VALUE("S268")==2)||(VALUE("S269")==1)||(VALUE("S269")==2)||(VALUE("S270")==1)||(VALUE("S270")==2))
  {  
  ADD("SegmentList",2);
  }

 else
  {  
  ADD("SegmentList",1,2);
  }

End Unverified

I may have assumed incorrectly so I will need you to confirm some issues.

I have assumed that if codes 1-2 are selected at (S261,S262,S263), display segment 1 only. This is the 1st priority.

If (S261,S262,S263) is not 1-2, then I check to see if (S264,S265,S266,S267,S268,S269,S270) is a code 1-2. If any are true, display segment 2 only. This is the 2nd priority.

If not codes 1-2 at any of S261-S270, both segment codes are to be displayed at the segment question. This is the 3rd priority.

You need to consider what segments to display if both (S261,S262,S263) is a codes 1-2 and (S264,S265,S266,S267,S268,S269,S270) is a code 1-2?

And what if none of S261-S270 are not codes 1-2?

I can modify the constructed list accordingly if you could provide these answers.

Also note that if only ONE code is displayed at a question, that question will NOT be displayed and the question will auto-fill with that respective code in the constructed list.
answered Jan 25 by Paul Moon Platinum (63,720 points)
Thanks Paul

Regarding your questions,

You need to consider what segments to display if both (S261,S262,S263) is a codes 1-2 and (S264,S265,S266,S267,S268,S269,S270) is a code 1-2?
Segment 1 Should be displayed.

And what if none of S261-S270 are not codes 1-2?
It should be skip to a question called disqualified text
Thanks Ossama.

The initial constructed list I provided was almost correct based on your additional information.

Try this constructed list ...
Begin Unverified Perl 
   
 if ((VALUE("S261")==1)||(VALUE("S261")==2)||(VALUE("S262")==1)||(VALUE("S262")==2)||(VALUE("S263")==1)||(VALUE("S263")==2))
  {  
   ADD("SegmentList",1);
  }
 
 elsif ((VALUE("S264")==1)||(VALUE("S264")==2)||(VALUE("S265")==1)||(VALUE("S265")==2)||(VALUE("S266")==1)||(VALUE("S266")==2)||(VALUE("S267")==1)||(VALUE("S267")==2)||(VALUE("S268")==1)||(VALUE("S268")==2)||(VALUE("S269")==1)||(VALUE("S269")==2)||(VALUE("S270")==1)||(VALUE("S270")==2))
  {  
  ADD("SegmentList",2);
  }
 
End Unverified

I can't ever see the segment question being displayed given only one code will ever be true. See my note in my earlier post at the bottom. You need 2+ codes to appear for the segment question to be displayed, otherwise the auto-fill feature will apply. To display the segment, add in a generic code like DK or Other when testing. And be sure to check your data when testing.
...