Difference between revisions of "Expressions"
Line 216: | Line 216: | ||
Example: | Example: | ||
ABS("Price" / "Quantity") | ABS("Price" / "Quantity") | ||
+ | |||
+ | |||
+ | ==== AVG function ==== | ||
+ | |||
+ | Returns the average of the values of a sequence of values. It can be used to return the average of different values of the same row of tables. | ||
+ | |||
+ | Syntax: | ||
+ | AVG(<expression 1>; <expression 2>; ...) | ||
+ | Example: | ||
+ | AVG("Taxes"; "Profit"; "Cost") | ||
+ | |||
+ | |||
+ | ==== BETWEEN function ==== | ||
+ | |||
+ | Checks whether a value is within the limits of the parameters used. Return true or false. | ||
+ | |||
+ | Syntax: | ||
+ | BETWEEN(<expression to be tested>; <initial limit>; <end limit>) | ||
+ | Example: | ||
+ | BETWEEN("Date Issued"; '01/01/2019'; '31/12/2019') | ||
+ | |||
+ | |||
+ | ==== IF ELSE function (If .... Otherwise ...) ==== | ||
+ | |||
+ | Tests a Boolean expression and applies a condition to true or another condition to false. You need three parameters, separated by semicolons (;). The first parameter is the expression to be tested, the second the value to be applied in case of true, and the third to be applied in case of false. | ||
+ | |||
+ | Syntax: | ||
+ | IF(<expression to be tested>; <expression if true>; <expression if false>) | ||
+ | Examples: | ||
+ | IF(BETWEEN("Value";0;100);10;250) | ||
+ | IF("Profit" == 0;0;"Profit" + "Taxes") | ||
+ | |||
+ | |||
+ | ==== LOG function ==== | ||
+ | |||
+ | Returns the logarithm of a number on a defined basis. It can be used with only one parameter, in this case the neperian (natural) logarithm is used . If two parameters are used, the second server to inform the base to be used by the logarithm. | ||
+ | |||
+ | Syntax: | ||
+ | LOG(<expression>;<base>) | ||
+ | Examples: | ||
+ | LOG("Profit") | ||
+ | LOG("Price";2) | ||
+ | |||
+ | |||
+ | ==== MAX function ==== | ||
+ | |||
+ | Returns the largest value between two values. | ||
+ | |||
+ | Syntax: | ||
+ | MAX(<expression 1>;<expression 2>) | ||
+ | Example: | ||
+ | "Value" / MAX("Quantity";1) | ||
+ | |||
+ | |||
+ | ==== MIN function ==== | ||
+ | |||
+ | Returns the smallest value between two values. | ||
+ | |||
+ | Syntax: | ||
+ | MIN(<expression 1>; <expression 2>) | ||
+ | Example: | ||
+ | "Value" / MIN("Cost"; 100) | ||
</translate> | </translate> |
Revision as of 19:39, 20 November 2019
You can create expressions (formulas) directly in the dashboard components. It can thus display calculated values that are not present in the data source file/spreadsheet.
To create the expression (formula) in the components, the component must support the addition of the special column Expression (Formula).
Below are details about how the expressions work:
Contents
Basic structure of a Expression (Formula)
Value Operand
It's the numerical values. You can use both while values and decimal values. For decimal values, the decimal separator should be the point.
- Examples: 1, 1.05, 2.55
Text Operand
It's the text operands. If you want to use this type of operand in a expression, you must delimit them by the single quotation mark (').
- Examples: 'John Snow', 'California', 'Spaghetti'
Date Operand
These are values that express any date. To represent a date in expressions the behaviour is similar to text operands, i.e. the content must be surrounded by single quotation marks ('). However, the mask dd/MM/yyyy must be used.
- Examples: '01/01/2019', '14/11/2019', '25/12/2019'
Boolean Operand
They're operators of the true or false type. Normally user to validate, or not, a condition in a more complex expression.
- Examples: true, false
Parentheses
Used to group and separate parts of on expression. Expressions within parentheses are processed first.
- Example: ("Profit"/"Total Price") + 10
System variable Operand
These are predefined variables in the system. To use the system variables you must precede them by hashtag (#) and delimit them by double quotes("). Currently only the "#null" variable is available and indicates null content.
- Example: IF("Product" == "#null";0;20)
Arithmetic Expressions
Arithmetic expressions relate two operands (which can be any the operands described above, or another expression) to make up the sum, subtraction, multiplication or division.
Sum (+)
Add two value operands or another expression result. Represented by the + charecter.
Syntax:
<operating or expression result> + <operating or expression result>
Example:
"Taxes" + "Commissions"
Subtraction (-)
Subtract two value operands or another expression result. Represented by the - charecter.
Syntax:
<operating or expression result> - <operating or expression result>
Example:
"Price" - "Taxes"
Multiplication (*)
Multiplies two value operands or another expression result. Represented by the multiplication charecter *.
Syntax:
<operating or expression result> * <operating or expression result>
Example:
"Quantity" * "Unit Price"
Division (/)
Divide two value operands or another expression result. Represented by the division charecter /.
Syntax:
<operating or expression result> / <operating or expression result>
Example:
"Price" / "Quantity"
Relational Expressions
Relational expressions compare two operands (value/text or other expression) to assess whether a condition is true or false. Normally used with decision functions, such as IF.
Equality (==)
It compares if two operands are the same, returning true if they are the same or false if they are different. Represented by the equality operator ==.
Syntax:
<operating or expression result> == <operating or expression result>
Example:
IF("Product" == "#null";0;20)
Different (!=)
It compare if two operands are different, returning true if they were different or false if equal. Represented by the differente operator !=.
Syntax:
<operating or expression result> != <operating or expression result>
Example:
IF("Product" != 'Lasagna';0;20)
Greater than (>)
Compares if the first operator (from the left) is greater than the second operator (from the right), returning true if it is greater and false if it is lesser or equal. Represented by the greater operator >.
Syntax:
<operating or expression result> > <operating or expression result>
Example:
IF("Gross Value" > 1000;1;0)
Greater or equal to (>=)
Compares if the first operator (from the left) is greater or equal to the second operator (from the right), returning true if it is greater or equal and false if it is lesser. Represented by the greater or equal operator >=.
Syntax:
<operating or expression result> >= <operating or expression result>
Example:
IF("Gross Value" >= 2500;100;0)
Less than (<)
Compares if teh first operator (from the left) is lesser than the second operator (from the right), returning true if it is lesser and false if it is greater or equal. Represented by the Lesser operator <.
Syntax:
<operating or expression result> < <operating or expression result>
Example:
IF("Gross Value" < 100;50;200)
Less or equal to (<=)
Compares if the first operator (from the left) is lesser or equal to the second operator (from the right), returning true if it is lesser or equal and false if it is greater. Represented by the lesser or equal operator <=.
Syntax:
<operating or expression result> <= <operating or expression result>
Example:
IF("Gross Value" <= 500;100;0)
Logical Expressions
Logical expressions group together two operands (Boolean or other expression) to make up a logical expression, in order to evaluate the relationship of two Boolean operators to a true or false result. This type of expression is usually used for decision making, such as IF and with relational expressions.
And Operator (&&)
Executes the logical operation AND between two Boolean values. Both values must return true so that the result of the operation is true. Represented by the && operator.
Syntax:
<expression> && <expression>
Examples:
IF(("Price" > 0) && ("Seller" == 'John Snow');450;0) IF(("City" != "#null") && ("Product" != 'Lasagna');1;0)
Or Operator (||)
Performs the logical OR operation between two Boolean values. A two values must be true so that the result of the operation is true. Represented by the operator ||.
Syntax:
<expression> || <expression>
Examples:
IF(("Price" > 1000) || ("Profit" >= 50);75;55) IF(("City" != "#null") || ("Product" != 'Lasagna');1;0)
Denial Operator (!)
Performs the logical negation operation for a boolean value. If the result of the operation is true the negation operator converts to false and vice versa. Represented by the operator !.
Syntax:
!<expression>
Example:
IF(!BETWEEN("Delivery Date"; '01/01/2015'; '31/12/2015');2016;2015)
Auxiliary Functions
Basic helper functions are standard system functions and implement useful features for composing complex expressions.
ABS function
Function that returns the absolute numeric value of a base numeric value.
Syntax:
ABS(<value operator or expression>)
Example:
ABS("Price" / "Quantity")
AVG function
Returns the average of the values of a sequence of values. It can be used to return the average of different values of the same row of tables.
Syntax:
AVG(<expression 1>; <expression 2>; ...)
Example:
AVG("Taxes"; "Profit"; "Cost")
BETWEEN function
Checks whether a value is within the limits of the parameters used. Return true or false.
Syntax:
BETWEEN(<expression to be tested>; <initial limit>; <end limit>)
Example:
BETWEEN("Date Issued"; '01/01/2019'; '31/12/2019')
IF ELSE function (If .... Otherwise ...)
Tests a Boolean expression and applies a condition to true or another condition to false. You need three parameters, separated by semicolons (;). The first parameter is the expression to be tested, the second the value to be applied in case of true, and the third to be applied in case of false.
Syntax:
IF(<expression to be tested>; <expression if true>; <expression if false>)
Examples:
IF(BETWEEN("Value";0;100);10;250) IF("Profit" == 0;0;"Profit" + "Taxes")
LOG function
Returns the logarithm of a number on a defined basis. It can be used with only one parameter, in this case the neperian (natural) logarithm is used . If two parameters are used, the second server to inform the base to be used by the logarithm.
Syntax:
LOG(<expression>;<base>)
Examples:
LOG("Profit") LOG("Price";2)
MAX function
Returns the largest value between two values.
Syntax:
MAX(<expression 1>;<expression 2>)
Example:
"Value" / MAX("Quantity";1)
MIN function
Returns the smallest value between two values.
Syntax:
MIN(<expression 1>; <expression 2>)
Example:
"Value" / MIN("Cost"; 100)