aggrexpression ::= ( fieldref |
operator1 aggrexpression |
aggrexpression operator2 aggrexpression |
functioninaggr |
( aggrexpression ) )
fieldref is a field name.
functionaggr ::= functionname ( parameters2 )
Expressions and functions can thus be nested freely, as long asfieldref is always enclosed by exactly one aggregation function and provided the expression returns an interpretable value, Qlik Sense does not give any error messages.
4 Operators
This section describes the operators that can be used in Qlik Sense. There are two types of operators:
l Unary operators (take only one operand)
l Binary operators (take two operands) Most operators are binary.
The following operators can be defined:
l Bit operators
l Logical operators
l Numeric operators
l Relational operators
l String operators
4.1 Bit operators
All bit operators convert (truncate) the operands to signed integers (32 bit) and return the result in the same way. All operations are performed bit by bit. If an operand cannot be interpreted as a number, the operation will return NULL.
bitnot Bit inverse. Unary operator. The operation returns the logical inverse of the operand performed bit by bit.
Example:
bitnot 17returns -18
bitand Bit and. The operation returns the logical AND of the operands performed bit by bit.
Example:
17 bitand 7returns 1
bitor Bit or. The operation returns the logical OR of the operands performed bit by bit.
Example:
17 bitor 7returns 23
bitxor Bit exclusive or.
The operation returns the logical exclusive or of the operands performed bit by bit.
Example:
17 bitxor 7returns 22
>> Bit right shift.
The operation returns the first operand shifted to the right. The number of steps is defined in the second operand.
Example:
8 >> 2returns 2
<< Bit left shift.
The operation returns the first operand shifted to the left. The number of steps is defined in the second operand.
Example:
8 << 2returns 32
4.2 Logical operators
All logical operators interpret the operands logically and return True (-1) or False (0) as result.
not Logical inverse. One of the few unary operators. The operation returns the logical inverse of the operand.
and Logical and. The operation returns the logical and of the operands.
or Logical or. The operation returns the logical or of the operands.
Xor Logical exclusive or. The operation returns the logical exclusive or of the operands. I.e. like logical or, but with the difference that the result is False if both operands are True.
4.3 Numeric operators
All numeric operators use the numeric values of the operands and return a numeric value as result.
+ Sign for positive number (unary operator) or arithmetic addition. The binary operation returns the sum of the two operands.
- Sign for negative number (unary operator) or arithmetic subtraction. The unary operation returns the operand multiplied by -1, and the binary the difference between the two operands.
* Arithmetic multiplication. The operation returns the product of the two operands.
/ Arithmetic division. The operation returns the ratio between the two operands.
4.4 Relational operators
All relational operators compare the values of the operands and return True (-1) or False (0) as the result. All relational operators are binary.
< Less than A numeric comparison is made if both operands can be interpreted numerically. The operation returns the logical value of the
evaluation of the comparison.
<= Less than or equal
A numeric comparison is made if both operands can be interpreted numerically. The operation returns the logical value of the
evaluation of the comparison.
> Greater
than
A numeric comparison is made if both operands can be interpreted numerically. The operation returns the logical value of the
evaluation of the comparison.
>= Greater
than or equal
A numeric comparison is made if both operands can be interpreted numerically. The operation returns the logical value of the
evaluation of the comparison.
= Equals A numeric comparison is made if both operands can be interpreted numerically. The operation returns the logical value of the
evaluation of the comparison.
<> Not equivalent to
A numeric comparison is made if both operands can be interpreted numerically. The operation returns the logical value of the
evaluation of the comparison.
precedes Unlike the < operator no attempt is made to make a numeric interpretation of the argument values before the comparison. The operation returns true if the value to the left of the operator has a text representation which, in string comparison, comes before the text representation of the value on the right.
Example:
' 11' precedes ' 2'returns True compare this to:
' 11' < ' 2'returns False
follows Unlike the > operator no attempt is made to make a numeric interpretation of the argument values before the comparison. The operation returns true if the value to the left of the operator has a text representation which, in string comparison, comes after the text representation of the value on the right.
Example:
' 23' follows ' 111'returns True compare this to:
' 23' > ' 111'returns False
4.5 String operators
There are two string operators. One uses the string values of the operands and return a string as result. The other one compares the operands and returns a boolean value to indicate match.
& String concatenation. The operation returns a text string, that consists of the two operand strings, one after another.
Example:
'abc' & 'xyz'returns 'abcxyz'
like String comparison with wildcard characters. The operation returns a boolean True (-1) if the string before the operator is matched by the string after the operator. The second string may contain the wildcard characters * (any number of arbitrary characters) or ? (one arbitrary character).
Example:
'abc' like 'a*'returns True (-1) 'abcd' like 'a?c*'returns True (-1) 'abc' like 'a??bc'returns False (0)