Hiding a Category of a Question

From Q
Jump to navigation Jump to search

Removes a category from a question but does not rebase it. This is automating the process of right-clicking on a category and selecting Hide.

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