Tip: You can do this in modern surveys and the script is now available! For more information, see How do I record the sum from an Allocation question? (Modern Surveys).
This script allows you to store the total of an Allocation Grid question for use in reports, exports or follow-up questions.
Allocation Grid totals can be piped into follow-up questions using this format: "Earlier, you said that you spent
[%Allocation_Grid_Total%]..."
Detailed Steps
Add the Allocation Grid and a Numeric question to the survey:
- Click on the Questionnaire tab of the survey.
- Add an Allocation Grid question for which you'd like to retain the total.
- Add a Numeric question in which the total will be stored.
a. Right-click the Numeric question.
b. Select Hide to hide the Numeric question from respondents and click OK to confirm
Prepare the Script in Notepad:
- Open Notepad or a similar text editing tool.
- Copy the script below into Notepad.
- In the script in Notepad:
a. Replace ALLOCATION_GRID with the question name of the Allocation Grid question in the survey.
b. Replace ALLOCATION_GRID_TOTAL with the question name of the Numeric Question in the survey. - Save the completed script in Notepad
Note: The question names used in scripts are case-sensitive. Ensure that you use the exact question names as they appear in the Questionnaire tree of the survey.
Script:
/* Script Name: How do I record the sum from an allocation grid? To ensure your script works as expected, always copy the original script from the script library found in the support portal. Failure to use the most up to date script from the script library may cause unexpected results. */ int total = 0; foreach (ShowQuestionAction sqa in ALLOCATION_GRID.WorkflowSteps) { VerbatimQuestion vq =(VerbatimQuestion)sqa.VerbatimQuestion; if(vq.NumberValue != Nulls.NumberNull) { total = total + (int)vq.NumberValue; } } Set(ALLOCATION_GRID_TOTAL, total);
Insert the Script:
- Right-click the Allocation Grid and select Edit Scripts.
- Copy the completed script from Notepad into the On Exit section of the Allocation Grid question.
- Click Save.
- Click Validate and test your survey.
Comments
0 comments
Article is closed for comments.