Have an idea?

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

Value of additional benefit based on ACBC summed price

I am planning ACBC study with summed price.
I want to include another attribute with a benefit referring to the summed price of a given concept: e.g. if a summed price of a given concept is $100 I need to present he value of an additional benefit based on the price of this particular concept: you get $10 to buy other services [$10 is a 10% of summed price for a given concept].
Is it possible to have a java script calculating the value of an additional benefit based on given concept summed price? Also taking into account that some concept can have no additional benefit included.
asked Nov 15 by RafalNeska Bronze (770 points)
Hi Rafal,

Have a look at this post,

This goes through how you can identify the summed pricing attribute and use it in other calculations.  With a bit of work I think you can tweak it for your purposes


1 Answer

0 votes
Best answer
"Multi-Currency ACBC" in the Community Question Library can handle this.  You can download it from here and import it into your local question library, then add one or more copies of it to your survey:


There are a lot of steps to it, but hopefully the instructions are clear enough.  I can help answer any questions that remain.

If your new price field was just a tenth of the original price, you could just set the "calculate" setting to this:

calculate: function(originalPrice) {
    return originalPrice / 10;

But what you are doing is a little more special.  What you'll instead want to do is add this HTML to the level that should change the price if it appears:

<input type="hidden" class="multiCurrencyLevel" value="additionalBenefit"/>

Then the "calculate" setting could look something like this (assuming the new price is meant to be 50 more when this additional benefit applies):

calculate: function(originalPrice, properties) {
    var newPrice = originalPrice / 10;
    if (properties['additionalBenefit']) {
        newPrice += 50;
    return newPrice;
answered Nov 17 by Zachary Platinum Sawtooth Software, Inc. (212,950 points)
selected Nov 21 by RafalNeska
Thank you.
My idea was to modify attribute already visible on the screen based on summed price.
Multicurrency script creates new line/lines. It could work for me, but I would need script going like this:
-    For att additional benefit level1  return text “xxx”
-    For att additional benefit level2  return text “yyy” + value referring to summed price e.g. 10% of summed price + text “zzz”
-    Hide att additional benefit
Would you be able to help me with this?
"Multi-Currency ACBC" supports a "showOriginalPrice" setting which can be used to prevent the original price from displaying on the page.

With that addressed, is the only remaining need to hide the attribute that controls the additional benefit?
I need script to:
-    Hide the attribute that controls the additional benefit?
-    Insersts additional line in a conditional way:
o    If att additional benefit = level1 --> return text “xxx”
o    elsif att additional benefit = level2 --> return text “yyy” + value referring to summed price e.g. 10% of summed price + text “zzz”

or it is easier to implement: the script that inserts a value calculated based on summed price into the level text of att additional benefit, but only for level2 of att additional benefit
If we're hiding one attribute and adding another, then I'd say the easiest option would be to just change the one attribute to accomplish this functionality.  The first level would be "xxx" and the second would have some HTML field that would get set to display this calculated value.

If we're going to go this approach, how are your prices formatted?  Currency symbol and its location, number of decimals and decimal character, thousands separator, etc.
Currency symbol: “PLN” located after the price
No decimals
Thousands separator: „space”
Please add this to your price attribute label:

<input type="hidden" class="priceAttribute"/>

and this to where you want to display the special calculated value between "yyy" and "zzz":

<span class="calculatedPrice"></span>

In both cases, I recommend adding an internal label to the list item so this HTML doesn't show up in analysis.

Finally, add this script to your screener, choice, and/or calibration questions to get the intended behavior:

    var tbody = $('#[% QuestionName() %]_div .inner_table > tbody');
    var priceRow = $(tbody).find('.priceAttribute').closest('tr');
        var summedPrice = Number($(priceRow).children().eq($(this).closest('td').index()).text().replace(/(\s|PLN)/g, ''));
        var calculatedPrice = summedPrice / 10;
        var formattedPrice = calculatedPrice.toLocaleString('pl-PL') + 'PLN';

Note that line 7 is where the calculation for this special price is done.
I have tested the scripted and it did work as expected, but some respondents are reporting that instead of calculated value they see blank space. Any idea why it happens?
Doesn't ring any bells, but ACBC are really complex, so perhaps there's something you've applied to your ACBC that I just haven't thought about.  Are they blank 100% of the time for these users?  Is there anything in common about the affected users?

Would it be possible for you to share your file with support@sawtoothsoftware.com so I can take a closer look?