Professional > Interview scripting > Writing interview scripts > Keywords for data analysis > Totals and subtotals
 
Totals and subtotals
Totals and subtotals are useful in long response lists where you want to know the sum of the counts in the preceding elements. For example, in a list of holiday destinations you could create subtotals for each country or region and then a total for all countries or regions.
Subtotals count the number of answers between the subtotal element and the previous base, subtotal, or total element, whichever is the most recent. Totals count the number of answers between the total element and the previous base or total element, whichever is the most recent. If there is no previous subtotal, total, or base element, subtotals and totals start counting from the start of the response list. Both elements ignore statistical and other totalling elements, as well as any other elements whose ExcludedFromSummaries property is True.
If a response list is multiple choice and some respondents choose more than one answer, the subtotal or total shows the number of answers in the preceding elements, not the number of respondents who gave those answers. If you want to count respondents rather than answers, create a combined or net element as described in Combining categorical responses in analyses.
To create subtotal or total elements
Type the following in the question’s axis block:
Name 'Text' subtotal()Name 'Text' total()
Parameters
Name
The element’s name.
Text
The text you want to display in analyses for these elements.
Example
Destination "Which countries did you visit on your last
holiday abroad?" categorical [1..]
{
Europe
{
Austria, England, France, Germany, Ireland, Italy
},
Asia
{
China, India, Japan, Malaysia, Singapore
}
}
axis (
"{
Europe 'Europe' text(),
Austria..Italy,
AllEurope 'Subtotal (Europe)' subtotal(),
Asia 'Asia' text(),
China..Singapore,
AllAsia 'Subtotal (Asia)' subtotal(),
Total 'Total visits' total()
}"
);
See also
Keywords for data analysis