Have an idea?

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

How to call mother brand in a dynamic list if its any of sub-brands has been selected in a parent list?

I need to call mother brand in a constructed list if its any of sub-brands has been selected in a parent list?

Such as the mother brand is Telenore and the sub brands are Talkshawk and Talkshawk60

If either of both Talkshawk and Talkshwk60 selected in the parent list I need to display only Telenor in the constructed list instead of the sub brands. How it is possible in the earlier sawtooth versions?

Furthermore, I have to call the mother brands from multiple questions such as Top of Mind list (single response), Spont and aided awareness and need to display the mother brands in the later question.

Currently I am using AIC but it displays all the selected brands whereas I have to display only the mother brands even if they are not selected and their sub brands are selected.
asked Aug 26, 2014 by Rashid (230 points)

1 Answer

0 votes
You need to create seperate pre defined list with mother brand. Let say your list name is ''mainBrandList" with options

1. Brand1
2. Brand2
3. Brand3

Now let's say you have Q1 where you are asking sub-brand of these mother brand. Those options are


Now to call mother brand to another question you should create separate constructed list and use perl code to add mother brand here.  Let say my constructed list name is "MotherBrand", parent list shoud be "mainBrandList" for this constructed list.

Begin Unverified Perl
if(VALUE('Q1_1')==1 or VALUE('Q1_2')==1)
if(VALUE('Q1_3')==1 or VALUE('Q1_4')==1)
if(VALUE('Q1_5')==1 or VALUE('Q1_6')==1)
End Unverified

You need to call this "MotherBrand" List now where you want to use.

Let me know in case of more clarification.
answered Aug 26, 2014 by Rajesh Rana Gold (24,715 points)
Thank you very much Paul. The program is working now. I was actually calling constructed list in first question (M1) as has I have to remove few brands from the major list for the first question as well. However, providing predefined master brand list (MBL) the problem of the program has resolved.

My another question is if there is  any way to remove showing few brands in the predefined list in a question?  Or there is any other good logic to control this?
Great news. Good to see you got it working. And it's examples like this that help with your skills no doubt. You will be so much better next time when a problem like this arises.

With list building, you need to add the codes before you remove them.

Use list functions like ADD, AIC, ANC, AIE, etc. to add to your constructed list. You can use functions like this to only add the codes you desire.

To remove codes from your list, you can use list functions RIC, Remove, etc.

Best you look these functions up in the Sawtooth help for a better explanation. And you should practice and do some testing.
I am happy for Rashid, he could get help from forum.

Amazing Paul.
When I am trying to call single brand the code is working but when I am trying to call 2 or more brands it shows irrelevant brands.  Can you please check the given below code if I am missing something such as any bracket?

Begin Unverified Perl
if((VALUE("M1_c1")==1) || (VALUE("M1_c1")==7) || (VALUE("M1_c1")==8) || (VALUE("M2_r1_c1")==1) || (VALUE("M2_r7_c1")==1) || (VALUE("M2_r8_c1")==1) || (VALUE("M3_r1_c1")==1) || (VALUE("M3_r7_c1")==1) || (VALUE("M3_r8_c1")==1))
if((VALUE("M1_c1")==10) || (VALUE("M1_c1")==12) || (VALUE("M1_c1")==13) || (VALUE("M2_r10_c1")==1) || (VALUE("M2_r12_c1")==1) || (VALUE("M2_r13_c1")==1) || (VALUE("M3_r10_c1")==1) || (VALUE("M3_r12_c1")==1) || (VALUE("M3_r13_c1")==1))
end unverified

Thank you very much Paul and Rajesh for your wonderful help on this forum.
Firstly, I would correct your "end unverified" to "End Unverified". Not sure the affect this has but it may pose a problem?

I can't see any other obvious syntax errors in the script you provided. That looks good.

Double check you variable names. They must be spelt exactly as you defined them as Perl is case sensitive.

I'm not sure what you mean by ...

"When I am trying to call single brand the code is working but when I am trying to call 2 or more brands it shows irrelevant brands."

I would need a further explanation on "irrelevant brands".