Have an idea?

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

Fetch not selected categories from previous questions

I am trying to write a question will fetch responses from previous 3 questions. the problem I am facing is that the previous 3 questions are grid questions (by row), and each row has a drop down list of choices.  I need to fetch all the choices that the respondent has not chosen in the previous 3 questions.
asked May 4, 2017 by anonymous
I am using version 8. I have revised my script. I am not sure whether getvalue() function will return the position of the option in the dropdown menu.

Begin Unverified Perl
if (GETVALUE("Q13_1")==0) && (GETVALUE("Q13_2")==0) && (GETVALUE("Q14_r1_c1")==11) && (GETVALUE("Q16_r1_c1")==11))
if ((GETVALUE("Q13_3")==0) && (GETVALUE("Q14_r2_c1")==6) && (GETVALUE("Q16_r2_c1")==6))
 if ((GETVALUE("Q13_4")==0) && (GETVALUE("Q13_5")==0) && (GETVALUE("Q14_r3_c1")==10) && (GETVALUE("Q16_r3_c1")==10))
 if ((GETVALUE("Q13_6")==0) && (GETVALUE("Q14_r4_c1")==10) && (GETVALUE("Q16_r4_c1")==10))
  if ((GETVALUE("Q13_7")==0) && (GETVALUE("Q13_8")==0) && (GETVALUE("Q13_9")==0) && (GETVALUE("Q14_r5_c1")==6) && (GETVALUE("Q16_r5_c1")==6))
End Unverified
VALUE is fine.

Do a test survey and look at the variable names and data via the admin module.

If you see an Error 132 for example during testing, you know that is a Perl syntax issue.

If it passes beyond the questions, your conditions are an issue in your Perl code.

As I have not seen your script, I suspect you may not be including all variables? (e.g. Q14_r1_c2, Q14_r1_c3, Q16_r2_c3, Q16_r2_c3, etc.)

If you have multiple columns in your grids, you maybe omitting certain variables within the conditions also.

Your Perl code looks okay in regards to syntax.
How did you go reviewing all conditions? If you need further assistance, please let me know. Happy to assist.

I suspect you have not considered all columns within your Q14 and Q16 grids?
Thanks Paul..you were right..there was a syntax error in my perl code...
Glad you have it resolved.

1 Answer

+1 vote
Your product category definitions appear to be ...

Product category 1: Q13=1 or Q13=2 or Q14=row 1 or Q16= row 1
Product category 2: Q13=3 or Q14=row 2 or Q16=row 2
Product category 3: Q13=4 or Q13=5 or Q14=row 3 or Q16=row 3
Product category 4: Q13=6 or Q14=row 4 or Q16=row 4
Product category 5: Q13=7 or Q13=8 or Q13=9 or Q14=row 5 or Q16=row 5

Are questions Q13 / Q14 / Q16 asked always to give the conditions in your "if statements" a chance to be true?

Just one condition you may need to correct on your "if statement" ...

Product category 2: (VALUE("Q14_r2_c1")==0) should be (VALUE("Q14_r2_c1")==6)

Do you have only one column in your Q14 and Q16 grids? That's what your Perl script is telling me.
answered May 4, 2017 by Paul Moon Platinum (67,375 points)