This article describes how to remove a category from a variable set without rebasing it. This automates the process of right-clicking a category in a table and selecting Hide.
Requirements
A Displayr Enterprise user license, which includes the ability to add custom analysis menu items and QScripts. See How to Use QScripts in Displayr for more details.
Method
- In the Data Sources tree, hover and click + > Custom Code > QScript > New.
-
Paste the following code into the QScript editor:
var age = project.dataFiles[0].getQuestionByName('Age'); age.dataReduction.hide("Don't know");The first line of code above 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. You will need to update Age with the Label of your variable
The second line of the code modifies the variable age. It does so using the question’s Data Reduction, which 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. You will need to update Don't know with the category you would like to hide.
- Click the Play button in the QScript Editor toolbar to run the QScript:
- Click OK.
- Enter a file name for the QScript and click OK. This will save the QScript to your Displayr cloud drive and will then be available in all of your documents by going to QScript > Open > [QScript Name] from the Data Sources or Report tree. If you don't wish to save the QScript to the cloud drive, click Cancel in the QScript Editor.
Next
How to Hide/Unhide Variable Sets Selected from a List
How to Hide/Unhide Questions with Many Categories
How to Unhide All Hidden Questions
UPCOMING WEBINAR: The Roadmap for Market Researchers in the Age of AI