Have an idea?

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

How to combine previous 2 responses into 1 member of a constructed list?

Hello,

I have a grid question #3 where I list 9 brands and ask the respondent what percent of the time they've used each of the brands.  
1) Peanut M&Ms
2) Plain M&Ms
3-9) etc...

For the next question #4 I want to call back their response to q3 and ask them their satisfaction rating for each of the 9 brands they've tried. I started a constructed list with the ANE to 0 function and it seems to work fine.

However, since 2 of the brands are from the same company and I only want to show it once, e.g.
1) M&Ms
2-8) etc...

What is the instruction for the constructed list so that if they choose either 1 and / or 2 in question #3 they will see this answer choice in the follow-up question #4?
asked Nov 2, 2021 by Rick

1 Answer

+1 vote
 
Best answer
It sounds like you will need a different list that is just the brands and not the products.  You would then need to use unverified perl to add the items from that new list based on the response to Q3.  So in the example below, if item 1 or item 2 is selected I'm adding the first item from your 'newlist' which would be M&Ms.  Then if item 3 is selected I'm adding item 2 which is the next brand.  And so on...

Begin Unverified Perl

if (VALUE("Q3_1")==1 || VALUE("Q3_2")==1)
{ADD("NewList",1);}

if (VALUE("Q3_3")==1)
{ADD("NewList",2);}

if (VALUE("Q3_4")==1)
{ADD("NewList",3);}
End Unverified
answered Nov 2, 2021 by Jay Rutherford Platinum (50,145 points)
selected Nov 3, 2021 by Bahadir Ozkurt
I forgot to update a couple of spots, so I corrected it.
Thanks Jay! Sorry I'm a bit of a novice at this so I'd like to kindly request some additional clarification as it's not working for me just yet.

I dropped the above into a new constructed list named "CathetersCondensed". I changed "NewList" from your post to "CathetersCondensed" and selected "CathetersCondensed" as the row list in my follow-up question #q4. See below:

Begin Unverified Perl
if (VALUE("Q3CathetersByBrand_1")==1 || VALUE("Q3CathetersByBrand_2")==1)
{ADD("CathetersCondensed",1);}
 
if (VALUE("Q3CathetersByBrand_3")==1)
{ADD("CathetersCondensed",2);}
 
if (VALUE("Q3CathetersByBrand_4")==1)
{ADD("CathetersCondensed",3);}

if (VALUE("Q3CathetersByBrand_5")==1)
{ADD("CathetersCondensed",4);}

if (VALUE("Q3CathetersByBrand_6")==1)
{ADD("CathetersCondensed",5);}

if (VALUE("Q3CathetersByBrand_7")==1)
{ADD("CathetersCondensed",6);}

if (VALUE("Q3CathetersByBrand_8")==1)
{ADD("CathetersCondensed",7);}

if (VALUE("Q3CathetersByBrand_9")==1)
{ADD("CathetersCondensed",8);}

End Unverified
No worries, you'll be a pro in no time!  Okay, I may have misread your scenario.  If Q3 is a grid where you collect a percentage and you want to carry forward the items that gave a response greater than 0 for the Q4 List.  I am assuming the grid only has one column.  I gave you logic based on a select question.  So, you want to create a new Predefined list of just the brands.  So if the Q3RowList was:
1 Peanut M&Ms
2 Plain M&Ms
3 Snickers
4 Butterfinger

then you want a new predefined list of brands (I'll call it NewList):
1 M&Ms
2 Snickers
3 Butterfinger

For Q4 you need a constructed list (I'll call it Q4list) and in the logic we will look for any row item from Q3 with a value greater than 0.  Point to NewList as the parent list for Q4list and use this logic:
Begin Unverified Perl

if (VALUE("Q3_r1_c1") > 0 || VALUE("Q3_r2_c1") > 0) 
{ADD("NewList",1);}

if (VALUE("Q3_r3_c1") > 0)
{ADD("NewList",2);}

if (VALUE("Q3_r4_c1") >0)
{ADD("NewList",3);}
End Unverified
OK that worked perfectly thanks. One last wrinkle. In the Q3RowList items 5 and 9 are "other specify" answers. I want to return the text they entered into the specify box in Q3 for Q4. I have this in my "NewList":
[%ListLabel(Q3CathetersByBranRowList, 5)%]
but it's not correct, it just shows the other specify row item, not their text response.
Fantastic Rick!  You are well on your way.  Great catch and a good question.  For your 'NewList' you were close.  You need to call on the actual other specify text field, so you would use this:
This should be what you use for the first other specify in 'NewList'
 [% Q3CathetersByBrand_r5_other %]

This should be what you use for the second other specify in 'NewList'
[% Q3CathetersByBrand_r9_other %]

I believe your Q3 question is named Q3CathetersByBrand, which is what I referenced.
Just to clarify, instead of the text of 'Other (specify)' or whatever you had, you would use the code I provided for your text of those row items.
Perfectly clear thank you! On an unrelated note, is there a way to insert an image as a link a respondent could click on if they need to refer back?

For example I setup a text question with a product profile and then when the respondent proceeds they are asked questions about the new product. Instead of inserting the product profile image on every screen (or the respondent having to click back) is there a way to have a link that says "Product Profile" in the question and if the respondent needs a refresher they can click? Or a workaround of similar utility of course :)
There are a few ways to accomplish that with some Sawtooth Script.  One is the [% Tooltip %] script where you can show 'Review Here' and when they put their mouse over that text you can have a window show up with either text or an image.  This is great for a little more detail/definition of an item that isn't too text heavy.  To review an entire page they saw earlier of text I will usually use the [% Popup %] script and create a .htm file of the text you want and save it to your graphics folder in the program.
Perfect, got it with the popup script thank you!
Great to hear!  Now you have a whole new bag of tricks to work with.
Back to the constructed list issue as I've hit a roadblock in a different study. I have "Q25CSFDrainageHoleDistan": a grid, select question, 5 rows by 7 columns. Row 5 is "other specify".

I am trying to build a constructed list including the first 4 rows of q25 and the 5th row as the "other specify" text (if it was chosen). Following the above logic, I made a new predefined list, "q26list) with the 4 rows of q25 and the 5th row "[%Q25_r5_other%]".

My constructed list is as follows (with Q26list as the parent list). I think it's the command I'm choosing, but not sure. I tried value, AIC and now AIG but it hasn't worked. The question is simply skipped when testing.
Begin Unverified Perl

if (AIG("Q25CSFDrainageHoleDistan_r1") > 0)
{ADD("NewListQ26NEW",1);}

if (AIG("Q25CSFDrainageHoleDistan_r2") > 0)
{ADD("NewListQ26NEW",2);}

if (AIG("Q25CSFDrainageHoleDistan_r3") > 0)
{ADD("NewListQ26NEW",3);}

if (AIG("Q25CSFDrainageHoleDistan_r4") > 0)
{ADD("NewListQ26NEW",4);}

if (AIG("Q25CSFDrainageHoleDistan_r5") > 0)
{ADD("NewListQ26NEW",5);}
End Unverified
Also tried this as a workaround but no dice.

Begin Unverified Perl

if (VALUE("Q25CSFDrainageHoleDistan_r1_c1") > 0 || VALUE("Q25CSFDrainageHoleDistan_r1_c2") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r1_c3") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r1_c4") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r1_c5") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r1_c6") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r1_c7") > 0)
{ADD("NewListQ26NEW",1);}

if (VALUE("Q25CSFDrainageHoleDistan_r2_c1") > 0 || VALUE("Q25CSFDrainageHoleDistan_r2_c2") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r2_c3") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r2_c4") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r2_c5") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r2_c6") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r2_c7") > 0)
{ADD("NewListQ26NEW",2);}

if (VALUE("Q25CSFDrainageHoleDistan_r3_c1") > 0 || VALUE("Q25CSFDrainageHoleDistan_r3_c2") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r3_c3") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r3_c4") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r3_c5") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r3_c6") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r3_c7") > 0)
{ADD("NewListQ26NEW",3);}

if (VALUE("Q25CSFDrainageHoleDistan_r4_c1") > 0 || VALUE("Q25CSFDrainageHoleDistan_r4_c2") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r4_c3") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r4_c4") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r4_c5") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r4_c6") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r4_c7") > 0)
{ADD("NewListQ26NEW",4);}


if (VALUE("Q25CSFDrainageHoleDistan_r5_c1") > 0 || VALUE("Q25CSFDrainageHoleDistan_r5_c2") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r5_c3") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r5_c4") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r5_c5") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r5_c6") > 0 || 
VALUE("Q25CSFDrainageHoleDistan_r5_c7") > 0)
{ADD("NewListQ26NEW",5);}
End Unverified
I'd need a little more understanding of the structure.  Is the original grid question row based or column based in the direction of responses?  You indicated it was a grid select question.  Is it a single response or multiple response?  It would seem that it's probably row based and you are capturing a response (or responses) for each row item?  The only reason we went with a new predefined list in our previous discussion was you wanted to treat 2 different items as 1 item so it required us to taking a different route.  This one should be a bit more straight-forward once I understand the layout better.
Sure, so you are correct it's row based single response. Basically a rating scale 1 through 7 up top and 4 rows to be rated plus a 5th "other" row.
Okay, this should be pretty easy then.  Use your rowlist from Q25CSFDrainageHoleDistan as the parent list for a new constructed list.  Your logic for your constructed list will simply be this:

AIG (Q25CSFDrainageHoleDistan,0)

That's it.  We are adding any item from that rowlist if the value at that question is greater than 0.
Thanks got it!
...