Qlik Sense Operators – Learn 5 Types in 6 Mins

FREE Online Courses: Knowledge Awaits – Click for Free Access!

Earlier, we saw an article on Qlik Sense Selections. In this lesson, we will learn about the Qlik Sense Operators. We cannot carry any operation in the script without using operators in the script expressions properly. So, here is an account of all the types of operators in Qlik Sense.

So, let’s start Qlik Sense Operators Tutorial.

Qlik Sense Operators - Learn 5 Types in 6 Mins

Qlik Sense Operators – Learn 5 Types in 6 Mins

1. What are Qlik Sense Operators?

Operators are the signs with predefined functions to perform upon the operand values. Operands are the one or two values on either side of the operator which are evaluated according to the operator between them and a suitable result is returned. In Qlik Sense, like usual, two types of operators are used i.e., unary operators and binary operators. Operators broadly categorize into categories like bit operators, logical operators, numeric operators, relational operators and string operators based on the values under evaluation and the purpose of the evaluation.

2. Types of Operators in Qlik Sense

So, following are the type of Qlik Sense Operators.

  • Qlik Sense Bit Operators
  • Qlik Sense Logical Operators

  • Qlik Sense Numeric Operators

  • Qlik Sense Relational Operators

  • Qlik Sense String Operators

Let’s discuss them in detail –

i. Qlik Sense Bit Operators

The Bit Operators in Qlik Sense evaluate a given numerical value bit by bit and returns a 32-bit signed integer value. This type of conversion of a simple numeric value into a 32-bit value only occurs on the numerical values, otherwise, the function returns NULL. Given below are the bit operators used in Qlik Sense script.

  • Bitnot operator: It is a unary operator which is also known as a bit inverse operator and returns the logical inverse of the operand evaluated bit by bit. For example, bitnot 17 returns -18 as the logical inverse of 17.
  • Bitand operator: Known as the ‘bit and’ operator, returns the logical AND of the operands evaluated bit by bit. For example, 17 bitand 7 returns 1.
  • Bitor operator: It is the ‘Bit or’ operator and returns the logical OR of the operands evaluated bit by bit. For example, 17 bitor 7 returns 23.
  • Bitxor operator: It is the ‘Bit exclusive or’ operator which evaluates and returns the logical exclusive OR of the operands. For example, 17 bitxor 7 returns 22.
  • >> operator: It is the ‘bit right shift’ operator which returns a value where the first operand is shifted to the right. You can set the number of steps in the second operand. For example, 8 >> 2 returns 2.
  • << operator: It is the ‘bit left shift’ operator which returns a value where the first operand is shifted to the left. You can set the number of steps in the second operand. For example, 8 << 2 returns 32.

ii. Qlik Sense Logical Operators

The logical operators evaluate the operands logically and returns a Boolean value, -1 (True) or 0 (False) depending upon the

Learn Qlik Sense Logical Functions in just 7 Mins

  • Not operator: It is the ‘Logical inverse’ operator which returns the logical inverse of the operand. It is a unary operator.
  • And operator: It is the ‘Logical and’ operator which returns the logical and of the operands.
  • Or operator: It is the ‘Logical or’ operator which returns the logical or of the operands.
  • Xor operator: It is the ‘Logical exclusive or’ operator which returns the logical exclusive or of the operands. This function is different from the Logical OR as this returns False if both the operands are True.

iii. Qlik Sense Numeric Operators

  • + operator: It can function as both the unary operator and a binary operator. The unary operator serves as the sign of a positive number for an operand like +12. The binary operator signifies arithmetic addition and the plus sign returns the sum of two operands.
  • – operator: It can function as both the unary operator and a binary operator. The unary operator serves as the sign of a negative number (i.e. the operand is multiplied by -1), like -12. The binary operator signifies arithmetic subtraction and the plus sign returns the difference of two operands.
  • * operator: This operator is for arithmetic multiplication which returns the product of the two operands between which this operator is applied.
  • / operator: This operator is for the arithmetic division which returns the ratio of the two operands between which this operator is applied.

You must know about Qlik Sense Mathematical Functions

iv. Qlik Sense Relational Operators

  • < operator: It is called the ‘Less than’ operator which evaluates two operands numerically and returns the True (-1) if operand1 (on the left) is lesser than operand2 (on the right). If this is not less, then it returns False (0).
  • <= operator: It is called the ‘Less than or equal’ operator which evaluates two operands numerically and returns the True (-1) if operand1 (on the left) is lesser than or equal to the value of operand2 (on the right). If this is not less or equal, then it returns False (0).
  • > operator: It is called the ‘Greater than’ operator which evaluates two operands numerically and returns the True (-1) if operand1 (on the left) is greater in value than operand2 (on the right). If this is not greater, then it returns False (0).
  • >= operator: It is called the ‘Greater than or equal’ operator which evaluates two operands numerically and returns the True (-1) if operand1 (on the left) is greater than or equal to the value of operand2 (on the right). If this is not greater or equal, then it returns False (0).
  • = operator: It is called the ‘Equals’ operator which evaluates the two operands present at the right and left of it for they are equal in value to each other. If yes, then it returns True (-1) and if not equal then it returns False (0).
  • <> operator: It is called the ‘Not equivalent to’ operator which evaluates the two operands and returns a result such that operand1 is not equal to operand2. For instance, the expression Price <> 20,000 will return all the values of the field Price which are not equal to 20,000.
  • Precedes operator: It is a string comparison operator which returns True (-1) if the operand on the left is less in value or comes before the operand on the right. This comparison takes place based on evaluating the ASCII value string character.  For example: ‘1 ‘ precedes ‘ 2’ returns FALSE because the value of ‘1’ is greater than or comes after the ‘ ’ (space) which exists in ‘ 2’. Whilst, ‘ 1’ precedes ‘2 ‘ returns TRUE as the ‘ ’ space comes before 2. It follows the fact that the ASCII value of a space (‘ ‘) is of less value than the ASCII value of a number.

You can understand it better upon comparing this to the < Operator in Qlik Sense where only numerical values are evaluated not the string.’1 ‘ < ‘ 2’ returns TRUE and ‘ 1’ < ‘ 2’ also returns TRUE because string representation does not matter and doesn’t the spaces.

  • Follows operator: It is a string comparison operator which returns True (-1) if the operand on the left is greater in value or comes after the operand on the right. This comparison takes place based on evaluating the ASCII value string character.  For example: ‘ 2’ follows ‘1 ‘ returns FALSE because the value of space in ‘ 2’ does not come after the value of the number 1 in ‘1 ’. Whilst, ‘ 2’ follows ‘1 ‘ returns TRUE as the ‘ ’ space comes before 2 and comes after the value of 1. It follows the fact that the ASCII value of a space (‘ ‘) is of less value than the ASCII value of a number.

You can understand it better upon comparing this to the > operator where only numerical values are evaluated not the string. ‘ 2’ > ‘ 1’ returns TRUE and ‘ 2’ > ‘1 ‘ also returns TRUE because string representation does not matter and so doesn’t the spaces.

v. Qlik Sense String Operators

  • & operator: It is known as the ‘String concatenation’ operator which returns a joined or combined string. It joins the strings provided as two operands like ‘abc’ & ‘xyz’ returns ‘abcxyz’ as a concatenated string.

Recommended Reading – Qlik Sense String Functions

  • Like operator: It is used for string comparison with wildcard characters. The operation returns a boolean True (-1) if the string of operand1 is matched with the string of the operand2. The second string may contain the wildcard characters like * or ? . Example: ‘abc’ like ‘a*’ returns True (-1) or ‘abcd’ like ‘a?c*’ returns True (-1) or ‘abc’ like ‘a??bc’ returns False (0).

So, this was all in Qlik Sense Operators. Hope you liked our explanation.

3. Summary – Qlik Sense Operators

Hence, this is all you need to know about the Qlik Sense Operators. This will help you understand what each operator is responsible for doing when we evaluate an expression in the script. So, learn about the operators and use them in your Qlik Sense data load script to manipulate the data as you like. Share your feedback of learning Qlik Sense through comments.

You must know Qlik Sense Career Opportunities

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *