# QlikView Operators – 5 Major Types of Operators in QlikView

## 1. Objective

In our last tutorial, we discussed **QlikView Backus Naur Form**. Today, we will learn what are QlikView Operators. Moreover, we will learn types of operators in QlikView: QlikView String Operators, Relational Operators, Numeric Operators, Logical Operators, Bit Operators, Binary Operators, and Unary Operators in QlikView with syntax and examples.

So, let’s start QlikView Operators Tutorial.

## 2. QlikView Operators

The word** Operator** must be a familiar one to you if you are well acquainted with the terms used in the word of computer science. While learning the basics of any computer language, you learn terms like data types, variables, operators etc. So, it is evident that understanding the operators is as important as learning anything else in a language like C, SQL, C++ etc. QlikView Operators are symbols or keywords which are used to apply mathematical operations on data values.

**QlikView Operator** is a symbol or a keyword which is used to perform an action on the data values it is used on. It is through reading the operators that the compiler of a computer understands what mathematical or logical function is to be applied to the values given during code execution. The data values on which the operator works and gives results are known as Operands or Arguments in QlikView.

**Do you know What is QMC and QMS API?**

For instance, if in a computer language we wish to multiply two digits (data items or data values), then the operator with the symbol, * (asterisk) will be used. In the expression 2*4, the Operator is ‘*’ and the Operands are the values 2 and 4. Depending on the number of Operands there are two types of QlikView Operators (also applicable in QlikView),

### i. Unary Operators in QlikView

The Unary Operators works only on one Operand. The format in which a unary operator typically appears is operator operand. Like -1, where – is the unary minus operator and 1 is the operand.

There are several unary operators like,

- Increment and Decrement operators having symbols (++) and (–) respectively.
- Single/Unary Plus and Minus operators having symbols (+) and (-) respectively.
- Not or negation operator with a symbol ‘!’ is also a unary operator.

### ii. Binary Operators in QlikView

The Binary Operator operates or works on two operands. The format is, operand1 operator operand2. Most of the QlikView operators used are binary type operators. Like the binary plus operator used for adding two numbers, 5+2, where + is the binary operator and 5 and 2 are the two operands.

## 3. Types of Operators in QlikView

Here, we will discuss five major types of QlikView Operators:

### i. Bit Operators in QlikView

As the name suggests, the bit or bitwise operators convert the normal data values or operands to a 32-bit integer form and perform operations and return results in the same form. The operand value is processed bit by bit and if an operand is not in the signed integer form then the bit operators return NULL. There are six-bit operators, bitnot, bitand, bitor, bitxor,>>, <<. Given below are all the bit operators explained with an example.

**Have a look – How to Create QlikView Master Calendar?**

**bitnot****(Bit inverse) –**It is a unary operator and returns the logical inverse of the operand performed bit by bit.

**Example: **bitnot 17 returns -18

**bitand****(Bit and)-**Returns the logical AND of the operands performed bit by bit.

**Example: **17 bitand 7 returns 1

**bitor****(Bit or) –**Returns the logical OR.

**Example:** 17 bitor 7 returns 23

**bitxor****(Bit exclusive or) –**Returns the logical exclusive or of the operands performed bit by bit.

**Example:**17 bitxor 7 returns 22

**>>****(Bit right shift) –**Returns the first operand shifted to the right. Example: 8 >> 2 returns 2

**<<****(Bit left shift) –**Returns the fir

### ii. Logical Operators in QlikView

The logical operators in QlikView are similar to the logical operators in other computer languages like C, C++. An operand value is interpreted logically and the results are presented as True (-1) or False (0). The logical operators used in QlikView are keywords like not, and, or, xor. They are explained in the table below.

**not****(Logical inverse) –**Returns the logical inverse of the operand.

**and****(Logical and) –**Returns the logical and of the operands.

**or****(Logical or) –**Returns the logical or of the operands.

**XOr****(Logical exclusive or) –**Returns the logical exclusive-or of the operands. i.e. like logical or. The results is False if both operands evaluate True.

### iii. Numeric Operators in QlikView

The numeric operators are the most commonly and widely used mathematical symbols like + – * / etc. These QlikView operators take up numerical values as it is, perform mathematical operations on them according to the operator and return a numeric value.

**+**Arithmetic addition returns the sum of the two operands.

**–**Arithmetic subtraction returns the operand multiplied by -1. and the binary the difference between the two operands.

*****Arithmetic multiplication returns the product of the two operands.**/**Arithmetic division returns the ratio between the two operands.

**Follow this link to know about QlikView Star Schema**

### iv. Relational Operators in QlikView

The relational operators, as the name suggests, analyses the relation between two operands and based on the result returns the value in True (-1) or False (0). There are two unique relational operators apart from the usual ones like greater than > , less than < etc. These are,

#### a. Precedes

The precedes operator returns True if the value on the left has less value in terms of string comparison than the value on the right. For example, if we put the precedes operator between two digits in string form,

‘ 2’ precedes ‘ 4’ returns TRUE

i.e. the string value of number 2 is less than or comes before 4 and so TRUE is returned.

If a number in the string form is compared with ‘ ‘ empty space then the expression would be,

‘1 ’ precedes ‘ 2’ returns FALSE

This is because the value on left (1) is not less than or comes before

(‘ ‘) empty space present in front of the number 2.

But with the normal relational Less than < operator only the numerical values and not strings are compared with each other,

‘ 3’ < ‘ 4’ returns TRUE

Or

‘3 ’ < ‘ 4’ returns TRUE

Space does not make a difference here.

#### b. Follows

With similar manner as that of ‘precedes’ operator, ‘follows’ operator returns True if the value (textually interpreted) on the left is followed by or is greater in value than the value on the right. Otherwise, False is returned. For instance,

‘ 6’ follows ‘ 5’ returns TRUE

While,

‘6 ’ follows ‘ 5’ returns FALSE

This is so because of the same empty space being considered and having a value in when interpreted as texts or strings. And the ASCII value of empty space (‘ ’) is less than that of numbers.

‘ 6’ > ‘ 5’ returns TRUE

‘6 ’ > ‘ 5’ returns FALSE

This is because the relational operator > interprets values numerically and only compares the values 6 and 5 without considering the ASCII value of the space.

**Do you know How to Create QlikView Data Files (QVD)?**

Given below are the generally used relational operators in QlikView.

**<****(Less than) –**Returns the logical value of the evaluation of the comparison. Example 7 < 8 returns True.

**<=****(Less than or equal) –**Returns the logical value of the evaluation of the comparison. For example, if you assign a condition 10 <= 20, then the result will be True because 10 is less than 20 and 20 <= 20 will also return True.

**>****(Greater than) –**Returns the logical value of the evaluation of the comparison. Example, 10 > 5 returns True.

**>=****(Greater than or equal) –**Returns the logical value of the evaluation of the comparison. Example 10 >= 5 returns True but 10 >= 12 returns False.

**=****(Equals) –**Returns the logical value of the evaluation of the comparison. 10 = 10 returns True.

**<>****(Not equivalent to) –**Returns the logical value of the evaluation of the comparison. It is used to assign a variable a value which it will not equate it to.

### v. String Operators in QlikView

The string operators & and like perform operations on the string values only. There are two main string operators which we are going to discuss. One is the ‘&’ operator which is the operator for string concatenation. It takes up two string operands and joins the two giving one combine string as a result.

The other string operator is the like operator which matches the two string operands on the right and left and returns the answer as a Boolean expression of TRUE or FALSE depending on whether the values on two sides are matching or not.

These QlikView operators are explained in further detail with an example below.

**&****(String concatenation) –**This operation returns a text string, that consists of the two operand strings, one after another.

** Example: **

abc’ & ‘xyz’ returns ‘abcxyz’

**like**– It is a string comparison with wildcard characters which 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 like * or ?.

Example:

abc’ like ‘a*’ returns True (-1)

abcd’ like ‘a?c”” returns True (-1)

abc’ like ‘a??bc’ returns False (0)

So, this was all about QlikView Operators. Hope you like our explanation.

## 4. Conclusion

We have discussed all the five types of QlikView operators used in scriptwriting namely, Bit, Logical, Relational, Numeric and String operators in QlikView. Each operator type comprises either of symbols or keywords and has a certain function to do.

We hope this explanation was helpful in strengthening your understanding of the topic QlikView Operators. In case of any doubts and queries, drop your comments in the comment box below.

Related Topic – **QlikView Navigation Pane**