Have an idea?

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

Displaying a conditional price calculated in perl in the CBC table

Dear Sawtooth users,

I pasted the perl code below (shown only for concept 1) into the footer of my CBC task in order to determine the displayed price tags for each of the 4 concepts to reflect the contingency of brand, the price level and the respondent. The four price tags are actually correctly calculated and displayed in the FOOTER of each task. However, I am stuck to move them into the appropriate places in the CBC table. I found previous js code snippets that are supposed to do this for CBC tasks formatted as tables, but they do not seem to work for me. Looking at the html of my CBC tasks, it seems to be a carousel. Is that the reason? What am I missing? Any help highly appreciated.

Thank you!
My best,
Christoph


[% Begin Unverified Perl
my $concept = 1;
my $currency = "€ ";
my $price = 0;

# brand contingency of price
my $att1 = CBCDESIGNLEVELVALUE(QUESTIONNAME(), $concept, 1);
if ($att1 == 1) { $price += 1; }
elsif ($att1 == 2) { $price += 1; }
elsif ($att1 == 3) { $price += 0.85; }
elsif ($att1 == 4) { $price += 0.75; }

# price level contingency of price
my $att2 = CBCDESIGNLEVELVALUE(QUESTIONNAME(), $concept, 7);
if ($att2 == 1) { $price *= 0.85; }
elsif ($att2 == 2) { $price *= 0.9; }
elsif ($att2 == 3) { $price *= 0.95; }
elsif ($att2 == 4) { $price *= 1.0; }
elsif ($att2 == 5) { $price *= 1.05; }
elsif ($att2 == 6) { $price *= 1.1; }
elsif ($att2 == 7) { $price *= 1.15; }


# respondent contingency of price & rounding and formatting
$price *= GETVALUE('io_PocketPreis');
$price = ROUNDTONUMBER($price,50);
$price = FORMATNUMBER($price,".",",",0 );

# Return
return $currency . $price;
End Unverified %]

 
asked Nov 9 by Christoph_Ihl (120 points)

Your answer

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...