Developer Documentation Library > Scripting > Expressions > Operators > Arithmetic operators > Subtraction (-) operator
 
Subtraction (-) operator
Double
Long
Text
Categorical
Date
Double
Subtract Double
Subtract Double
Subtract1 Double
Not applicable
Subtract2 Date
Long
Subtract Double
Subtract Long
Subtract1 Long
Subtract Categorical
Subtract2 Date
Text
Subtract1 Double
Subtract4 Double5
Not applicable
Subtract3 Categorical
Subtract4 Date
Categorical
Not applicable
Subtract Categorical
Subtract3 Categorical
Subtract Categorical
Not applicable
Date
Subtract2 Date
Subtract2 Date
Subtract4 Date
Not applicable
Subtract Date
Examples
Numeric variables
(whales - dinosaurs) > 0
The whales and dinosaurs variables are numeric (Long) variables that record the rating, on a scale of 1-5, that respondents gave to the Whale and Dinosaur galleries respectively. The expression subtracts the rating given to the Dinosaur gallery from the rating given to the Whale gallery and compares whether the result is greater than 0. For example, you could use this expression to select respondents for whom the difference between the two ratings is greater than zero.
Categorical variables
(remember - interest) >= {FOSSILS}
This example uses the remember and interest categorical variables again. remember is a multiple response variable that records which galleries the respondents remember viewing, and interest is a single response variable that records which gallery respondents found most interesting. In this example, the - operator removes the responses given to the interest question from the responses given to the remember question. The >= operator then tests whether the resulting list of categories includes the Fossils category. You could use this expression to create a filter to select respondents who remember the Fossil gallery, but who did not find it the most interesting gallery.
The - operator is generally useful for categorical variables only if they have identical or overlapping category lists.
See
Arithmetic operators