Have an idea?

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

Anchor Text based on pass-in variable

Hi everyone,

I need to customize the text of a MaxDiff anchor based on a Pass-in Variable.
For example:
variable "indicator" gets passed into the MaxDiff. Dependung on this Variable my anchor text  should use different blocks of text [TEXT A] and [TEXT B].

For example:
For indicator = 1,
the anchor text should be: "Considering the [TEXT A] ...."
For indicator=2,
the anchor text should be:  "Considering the [TEXT B] ...."

Thanks a lot for your help!

asked Feb 7 by Simon

1 Answer

0 votes
Best answer
If it is simply question text you need to apply a condition to, try this Perl script ...
[%Begin Unverified Perl 

 my $MDText="";

 if (VALUE("indicator")==1) 
   $MDText="Considering the [TEXT A] ...."; 
 elsif (VALUE("indicator")==2) 
   $MDText="Considering the [TEXT B] ...."; 

 return $MDText;
End Unverified%]

Insert this into your question where you would normally write your question script.

Good luck.
answered Feb 7 by Paul Moon Platinum (58,715 points)
Or, if the indicator is really going to be a 1, 2, 3..., (sequentially ordered numbers beginning with 1) you could create a list:

Then in the questions, simply call the ListLabel for that particular indicator, as shown:

Considering the [% ListLabel (IndicatorList, indicator) %] ....

where "IndicatorList" is the list name of your list of text strings, and "indicator" is your pass-in field. (You'd probably want to store "indicator" as a numeric value rather than a text string to avoid having to convert a string to a number.)
Thanks Aaron. Yep, I use the ListLabel approach often which is a nice method.