QScript FilterTerm
FilterTerm
Examples of FilterTerms:
- "Gender is Male" (Question with value 1)
- "Age >= 18" (Question with numeric comparison)
- "Comments contains 'excellent'" (Question with text matching)
- "Satisfaction_Service >= 4" (Variable from a grid question)
FilterTerm objects are created using DataFile.createFilterTerm and can be:
- Used directly in DataFile.newFilterQuestion for simple filters
- Combined with LogicalAnd objects / LogicalOr objects for complex filtering logic
The values for filtering can come from:
- Direct values passed when creating the term (static filtering)
- A Control object (dynamic filtering based on user selection in the UI)
children
For FilterTerm objects (leaf nodes), this always returns an empty array.
For LogicalAnd objects and LogicalOr objects, returns the child conditions being combined.
controlGuid
equals(obj)
| obj | The object to compare against. |
| Returns: | true or false |
| Example: | data_file.getQuestionByName('Q2').equals(data_file.questions()[0])
|
input
For single-variable questions (Pick One, Number, Text, Date), this may be either a Question or Variable object.
For Pick Any questions, this will be a Question object.
For grid/multi questions (Pick One - Multi, Number - Multi, Pick Any - Grid, Number - Grid, Pick Any - Compact, Text - Multi), this will be a Variable object.
See DataFile.createFilterTerm for more details on input types.
isControlBased
label
negated
- For FilterTerm object: matches become non-matches and vice versa
- For LogicalAnd object: becomes NOT(A AND B AND ...) which is equivalent to (NOT A OR NOT B OR ...)
- For LogicalOr object: becomes NOT(A OR B OR ...) which is equivalent to (NOT A AND NOT B AND ...)
operator_string
Pick Any questions: "Any of", "All of", "Only/exactly", "None of"
Categorical (Pick One questions, or categorical variables from grids): "Any of", "None of"
Numeric: "Equals", "Not equals", "Greater than", "Greater than or equals", "Less than", "Less than or equals"
Text: "Equals", "Not equals", "Contains text", "Contains word", "Starts with", "Ends with", "Regular expression"
Date: "Within last", "Within last period", "Equals", "Not equals", "Greater than", "Greater than or equals", "Less than", "Less than or equals"
type
values
- Categorical single-response (Pick One): Array of numeric category codes
- Pick Any questions: Array of Variable objects representing selected categories
- Numeric: Array of numbers to compare against
- Text: Array of strings to match
- Date: Array of DateTime objects
For control-based filters, this returns the current values from the control.