Using Continuous Sum Total Later in Survey

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 Alchemer and Custom Scripting.

Check it out in an example survey!

OR

Add a survey with this setup to your account.

Setup

Features used in this script:

  1. Start by building all of your survey questions. In this example survey we have a continuous sum question on the first page.
  2. On the next page we have a custom script action with the below script, 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 --Continuous Sum QuestionID
hiddenvalue = 5 --QuestionID of hidden value that will store total


contsum_data = getvalue(contsum) 
finalval=0


for key,value in pairs(contsum_data) do

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

  val = str_replace(chars, '', value)  
  
  finalval = finalval + val
end


setvalue(hiddenvalue,finalval)

Required Customizations

In the script above you will need to customize two variables 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 Alchemer features and functionality ideas that might meet your needs. Beyond this, check out our Professional Services; these folks have the scripting chops to help you to achieve what you are looking for!

Basic Standard Market Research HR Professional Full Access Reporting
Free Individual Team & Enterprise
Feature Included In