Hiding a Category in a Pick One Question
This hides the "Don't Know" category from the table, but the category is still included in the table's base. This means respondents who chose "Don't know" are still included in the NET.
var age = project.dataFiles[0].getQuestionByName('Age');
age.dataReduction.hide("Don't know");
The first line of this code finds a question named Age in the first data file (note that [0] finds the first data file, [1] would find the second, etc. ) and assigns it to a variable called age.
The second line of the code modifies the question called age. It does so using the question’s DataReduction. The DataReduction is the object that stores which categories have been merged together, which have been hidden, what their names are and what order they are shown in. Thus, the hide instruction is hiding the Don’t know category and this will cause the category not to appear when this question is used to create tables and charts.
See also
- QScript for an explanation of how to run this code.
- QScript Examples Library for other examples.
- QScript Reference for technical information.
- JavaScript for information about the JavaScript programming language.
- Table JavaScript and Plot JavaScript for tools for using JavaScript to modify the appearance of tables and charts.
- JavaScript Variables for detail on how to create new variables in the Variables and Questions tab using JavaScript.