# [Solved] Using Continuous Sum Total in a Merge Code not displaying correct number

0

Love continuous sum. However, using your script on “Using Continuous Sum Total in a Merge Code” the continuous sum for my example is \$3500 and when it populate in the question merge it is \$35.

Even in your example survey, if I enter a number over 999 the value omits the thousands number. If I enter 20 and 30 as values, the pull is 50. If I enter 20, 30, and 1000, the value is 51.

Help is appreciated.

1

You spend over \$3,500 a month on beer?! Invite me over some time!

Lame joke aside, this example script seems to be failing because of the commas that are automatically added by the currency validation applied to the example question. Adding a comma to the %%chars array on line 10 will strip these out, and allow it to properly sum values over \$1,000.

Here’s an improved script that you can copy and paste:

%%continuousSumQuestion = 2; // Change this number to the ID of your continuous sum question
%%hiddenValue = 5; // Change the number to the ID of your hidden value action
%%nextPage = 4; // Change this number to the ID of the following page

%%totalSum = 0;
%%rowValues = sgapiGetValue(%%continuousSumQuestion);

foreach (%%rowValues as %%rowSku => %%rowValue)
{
%%charsToRemove = array(‘,’,’%’,’\$’,’₠’,’₡’,’₢’,’₣’,’₤’,’₥’,’₦’,’₧’,’₨’,’₩’,’₪’,’₫’,’€’,’₭’,’₮’,’₯’,’₱’,’₲’,’₳’,’₴’,’₵’,’₶’,’₷’,’₸’,’₹’);
%%cleanedValue = sgapiStr_Replace(%%charsToRemove, ”, %%rowValue);
%%totalSum += %%cleanedValue;
}

sgapiSetValue(%%hiddenValue, %%totalSum);
sgapiJumpToPage(%%nextPage);

0

Hey everybody,

Thanks for catching the mistake in our document.  We updated the article and the example survey accordingly:

0

What? Don’t you spend that much?  I am from Chicago so that may have something to do with it…. Thanks…. I will give that script a try