This blog will approach every Boolean Operator for creating new key figures within your system.
If you want to check another available operators, please check the blog posts below:
-
- Mathematical Operators: https://blogs.sap.com/2019/04/17/creating-key-figures-mathematical-operators/
-
- Trigonometric Operators: https://blogs.sap.com/2019/04/24/creating-key-figures-trigonometric-operators/
What is a Boolean Operator?
Boolean Operators are used to combine the logical expressions to produce a single output. Logical expression is a combination of one or more operands with a relational operator. Logical expression output is either true or false.
Boolean Operators in your system
-
- AND
-
- EQ
-
- GE
-
- GT
-
- LE
-
- LT
-
- NE
-
- NOT
-
- OR
-
- XOR
-
- LEAF
I’m going to provide with a practical example on the operators. Please consider the formulas used and change their values as below:
ValueOrKeyFigureToBeCompared1 = Confirmed Quantity
Criteria1 = 50
ValueOrKeyFigureToBeCompared2 = Ordered Quantity
Criteria2 = 50
After the explanation of each Boolean Operator, you will find a table with example of possible results based on the provided values and formulas.
AND
AND is a logical operator which will return the Boolean value 1 (when it’s true) if all involved analyzed operands are true, otherwise it will return the value 0.
Example: AND(GT(“ValueOrKeyFigureToBeCompared1”, “Criteria1”)), GT(“ValueOrKeyFigureToBeCompared2”,”Criteria2”))
EQ
The logical operator EQ will analyze if a value or key figure is equal to a previously specified value or key figure.
Example: EQ(“ValueOrKeyFigureToBeCompared1”,”Criteria1”).
GE
The logical operator GE will analyze if a value or key figure is greater than or equal to a previously specified value or key figure.
Example: GE(“ValueOrKeyFigureToBeCompared1”,”Criteria1”).
GT
The logical operator GT will analyze if a value or key figure is greater than a previously specified value or key figure.
Example: GT(“ValueOrKeyFigureToBeCompared1”,”Criteria1”).
LE
The logical operator LE will analyze if a value or key figure is less than or equal to a previously specified value or key figure.
Example: LE(“ValueOrKeyFigureToBeCompared1”,”Criteria1”).
LT
The logical operator LT will analyze if a value or key figure is less than a previously specified value or key figure.
Example: LT(“ValueOrKeyFigureToBeCompared1”,”Criteria1”).
NE
The logical operator NE will analyze if a value or key figure is not equal to a previously specified value or key figure.
Example: NE(“ValueOrKeyFigureToBeCompared1”,”Criteria1”).
NOT
NOT is a negation logical complement and it has to be used with another logical operators. Its single formula is NOT(“Criteria”).
Example: AND(NOT(GT(“ValueOrKeyFigureToBeCompared1”, “Criteria1”)),NOT(GT(“ValueOrKeyFigureToBeCompared2”,”Criteria2”)))
OR
OR is a logical operator which will return the Boolean value 1 (when it’s true) if at least one of the involved analyzed operands is true, otherwise it will return the value 0.
Example: OR(GT(“ValueOrKeyFigureToBeCompared1”, “Criteria1”)), GT(“ValueOrKeyFigureToBeCompared2”,”Criteria2”))
XOR
XOR is also called as exclusive or, it returns true only if one of the analyzed criteria is true and the other one is false.
Example: XOR(GT(“ValueOrKeyFigureToBeCompared1”, “Criteria1”)), GT(“ValueOrKeyFigureToBeCompared2”,”Criteria2”))
LEAF
LEAF Boolean operator is used to define hierarchy in the report. It will be started as 0 for the root node and proceeding downward to a leaf. The value for the result rows will be zero, while the elementary row (the last one in the hierarchy) will be shown as 1.
This operator can help you to have several types of calculation on result rows and elementary rows. Also, the result row will be always 0 if your report is not displayed in hierarchy.
Let’s suppose that you have created the key figure with the following formula LEAF(“COUNTER”), the result would be like the example below:
As you can see, the elementary row is the value for Product ID, so its result will be 1.
Table with examples for Boolean Operators
I hope you all have been able to understand a bit more on Boolean Operators. If you have any doubt, please do not hesitate on commenting them below.