Using Continuous Sum Total in a Merge Code

Important Update to Custom Scripting

SurveyGizmo's CustomScript Action now supports the LUA programming language. Visit our NEW Lua Scripting Resources!

Legacy Custom Scripting Language Deprecation Plans 

  1. New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
  2. As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
  3. In the long term, Legacy Custom Scripting Actions will be switched to read-only. The exact date on this is to be determined; we will send notifications well ahead of time.

There isn't a built in way to use the total of the Continuous Sum question in another question. Fret not! There's a custom script for that! In this tutorial we'll show you how to use a custom script to populate a hidden value so that you can use the total later on in your survey. These steps assume a basic familiarity with SurveyGizmo and Custom Scripting.

Check it out in an example survey!


Add a survey with this setup to your account.


Features used in this script:

  • Custom Script Action
  • Continuous Sum Question
  • Hidden Values
  • sgapiGetValue
  • sgapiSetValue
  • sgapiJumpToPage

Start by building all of your survey questions. In this example survey we have a continuous sum question on the first page.

On the next page we have a custom script action with the script below followed by a hidden value.  This hidden value will be populated by the script.  You can then use the merge code for the hidden value in later questions or text. In this case the merge code would be for question ID 5: [question("value"), id="5"].

%%contsum = 2; // The continuous sum questionID
%%hiddenvalue = 5; // The hidden value questionID

%%array = sgapiGetValue(contsum); 
%%moveto = %%hiddenvalue; 

foreach (%%array as %%key => %%value)

  %%chars = array(',','%','$','₠','₡','₢','₣','₤','₥','₦','₧','₨','₩','₪','₫','€','₭','₮','₯','₱','₲','₳','₴','₵','₶','₷','₸','₹');

  %%val = sgapiStr_Replace(%%chars, '', %%value);  
  %%finalval+= %%val;


sgapiJumpToPage(4); //Change this number to the page ID of the following page.

Required Customizations

In the script above you will need to customize variables highlighted in yellow in order to make the script work the way you'd like.

%%contsum - This is the Continuous Sum questionID.

%%hiddenvalue - This is the Hidden Value question ID where you wish to store the total.

Scripting and Other Custom Solutions

We’re always happy to help you debug any documented script that is used as is. That said, we do not have the resources to write scripts on demand or to debug a customized script.

If you have customization ideas that you haven't figured out how to tackle, we're happy to be a sounding board for SurveyGizmo features and functionality ideas that might meet your customization. Beyond this, you might want to consult with someone on our Programming Services Team; these folks might have the scripting chops to help you to achieve what you are looking for!