Page History
Learn more about the math functions available in Blueriq expressions, such as:
- The basic Basic math functions ADD, SUM, SUBTRACT, MULTIPLY, and DIVIDE;
- More advanced math functions like SUM, PRODUCT, DIV, MOD, POWER, and LOG;
- Rounding functions ROUND, ROUNDDOWN, ROUNDUP, ROUND TO MULTIPLE, ROUNDSIG, ROUNDSIGUP, and ROUNDSIGDOWN;
- Comparison operator functions EQUAL, NOT EQUAL, LESS, LESS OR EQUAL, GREATER, and GREATER OR EQUAL;
- And the special function ANNUITY.
...
Overview
...
minLevel | 2 |
---|
...
bgColor | white |
---|
Function | Description |
---|---|
ADD (+) |
...
Use the '+' (plus) sign to add values of some type of number. |
Syntax
Code Block |
---|
number1 + number2 + ... |
- number1 - First number or attribute of some type of number to add.
- number2 - Second number or attribute of some type of number to add.
Return types
- number + number = number
- integer + integer = integer
- currency + currency = currency
- percentage + percentage = percentage
- number + integer = number
- number + currency = currency
- number + percentage = percentage
- integer + currency = currency
- integer + percentage = percentage
- currency + percentage = error
Examples
Suppose the following data model:
...
bgColor | white |
---|
SUM
This function adds the values of a collection of numbers.
Syntax
Code Block |
---|
SUM ( collection ) |
- collection - A collection of number values.
Return types
- number
- integer
- currency
- percentage
Examples
Suppose the following data model.
...
bgColor | white |
---|
SUBTRACT
Use the '-' (minus) sign |
...
Syntax
Code Block |
---|
number1 - number2 - ... |
...
to subtract |
...
values |
...
of some type of number |
...
. |
...
bgColor | white |
---|
...
- number - number = number
- integer - integer = integer
- currency - currency = currency
- percentage - percentage = percentage
- number - integer = number
- number - currency = currency
- number - percentage = percentage
- integer - number = number
- integer - currency = currency
- integer - percentage = percentage
- currency - number = currency
- currency - integer = currency
- percentage - number = percentage
- percentage - integer = percentage
- currency - percentage = error
- percentage - currency = error
Examples
Suppose the following data model.
MULTIPLY (*) | Use the '*' (asterisk) sign to multiply values of some type of number. |
Syntax
Code Block |
---|
number1 * number2 * ... |
- number1 - First factor; number or attribute of some type of number.
- number2 - Second factor; number or attribute of some type of number.
Return types
- number * number = number
- integer * integer = number
- currency * currency = number
- percentage * percentage = number
- number * integer = number
- integer * number = number
- currency * number = currency
- currency * integer = currency
- percentage * number = percentage
- percentage * integer = percentage
- currency * percentage = currency
Examples
Suppose the following data model.
...
bgColor | white |
---|
PRODUCT
This function returns the product of the values of a collection of numbers.
Syntax
Code Block |
---|
PRODUCT ( collection ) |
- collection - A collection of number values.
Return types
- number
- integer
- currency
- percentage
Examples
Suppose the following data model.
...
bgColor | white |
---|
DIVIDE
Use the '/' (forward slash) sign to divide values of some type of number. |
Syntax
Code Block |
---|
number1 / number2 / ... |
- number1 - Dividend; number or attribute of some type of number to be divided by other number values.
- number2 - Divisor; number or attribute of some type of number to divide by.
Return types
- number / number = number
- integer / integer = number
- currency / currency = number
- percentage / percentage = number
- number / integer = number
- integer / number = number
- currency / number = currency
- currency / integer = currency
- percentage / number = percentage
- percentage / integer = percentage
- currency / percentage = currency
Examples
Suppose the following data model.
SUM | Adds the values of a collection of numbers. |
PRODUCT | Returns the product of the values of a collection of numbers. |
DIV | Returns |
...
bgColor | white |
---|
DIV
...
the integer portion of a division. |
...
Syntax
...
...
number1 DIV number2
- number1 - Dividend; number or attribute of some type of number to be divided by another number value.
- number2 - Divisor; number or attribute of some type of number to divide by.
Return type
- integer
Examples
Suppose the following data model. Attribute Child.pocketMoney is of type currency and has a value of 2.50. Attribute Bonus.standard is of type percentage and has a value of 5.00.
...
bgColor | white |
---|
MOD | Returns |
MOD
...
the remainder of a division. |
Syntax
Code Block |
---|
number1 % number2 |
- number1 - Dividend; number or attribute of some type of number to be divided by another number value.
- number2 - Divisor; number or attribute of some type of number to divide by.
Return types
- number % number = number
- integer % integer = integer
- currency % currency = currency
- percentage % percentage = percentage
- number % integer = number
- integer % number = number
- currency % number = currency
- currency % integer = currency
- percentage % number = percentage
- percentage % integer = percentage
Examples
Suppose the following data model.
...
bgColor | white |
---|
POWER (**) | Use the '**' operator to raise a number to a |
...
Syntax
Code Block |
---|
base ** exponent |
...
...
power |
...
. |
Return types
- number ** number = number
- integer ** integer = number
- number ** integer = number
- integer ** number = number
- currency ** number = currency
- currency ** integer = currency
- percentage ** number = percentage
- percentage ** integer = percentage
Examples
Suppose the following data model.
...
bgColor | white |
---|
LOG
Since 12.8
...
LOG | Calculates the logarithm of a number to a base. |
Syntax
Code Block |
---|
LOG([number], [base]) |
number- Number; number or attribute of some type of number.
- base - Base; number or attribute of some type of number.
Return types
number
Examples
...
bgColor | white |
---|
ROUND
ROUNDDOWN
ROUNDUP
ROUND | Rounds a number value to a specified number of decimal places. |
ROUND DOWN | Rounds a number value down |
...
to a specified number of decimal places. |
Syntax
Code Block |
---|
ROUND number [UP | DOWN] TO POSITION position |
- number - Number or attribute of some type of number to be rounded.
- UP or DOWN - The direction of rounding. The direction DOWN points to zero for both positive and negative values, UP points away from zero. If no direction is specified, rounding will be done to the nearest integer (half-way values will be rounded up).
- position - The rounding position as integer. A positive integer represents the place value of the digit after the decimal point. Zero and negative integers represent the place value of the digit before the decimal point. Place values: [-n]..[-3][-2][-1][0].[1][2][3]..[n]
Return types
- number
- integer
- currency
- percentage
UI Text Box | ||
---|---|---|
| ||
If you prefer a functional syntax, then you can use the ROUNDDOWN or ROUNDUP function. Its syntax is ROUNDDOWN/ROUNDUP ( number , digits ). Example: ROUNDDOWN( 1.23456 , 2 ) = 1.23 |
Examples
...
bgColor | white |
---|
ROUND TO MULTIPLE
ROUNDSIG
ROUNDSIGUP
ROUNDSIGDOWN
The ROUND TO MULTIPLE function rounds a number value to a specified multiple.
Syntax
Code Block |
---|
ROUND number [UP | DOWN] TO MULTIPLE multiple |
- number - Number or attribute of some type of number to be rounded.
- UP or DOWN - The direction of rounding. The direction DOWN points to zero for both positive and negative values, UP points away from zero. If no direction is specified, rounding will be done to the nearest multiple (half-way values will be rounded up).
- multiple - The multiple to be rounded to. This can be both a positive and negative value of any number type.
Return types
- number
- integer
- currency
- percentage
Examples
...
UI Text Box | ||
---|---|---|
| ||
If you prefer a more functional syntax, you can use the ROUNDSIG, ROUNDSIGDOWN or ROUNSIGUP functions, all with 2 number parameters. |
...
bgColor | white |
---|
EQUAL
ROUND UP | Rounds a number value up to a specified number of decimal places. |
ROUND TO MULTIPLE | Rounds a number value to a specified multiple. |
ROUND UP TO MULTIPLE | Rounds a number value up to a specified multiple. |
ROUND DOWN TO MULTIPLE | Rounds a number value down to a specified multiple. |
ROUNDSIG | Alternative syntax for ROUND TO MULTIPLE. |
ROUNDSIGUP | Alternative syntax for ROUND UP TO MULTIPLE. |
ROUNDSIGDOWN | Alternative syntax for ROUND DOWN TO MULTIPLE. |
EQUAL (=) |
...
1.0 = 1.0
...
bgColor | white |
---|
NOT EQUAL
The operator '=' compares two values and returns the boolean value TRUE if the left value is equal to the right value and FALSE otherwise. |
Syntax
Code Block |
---|
value1 = value2 |
- value1 - Number, date or attribute of some type of number or date.
- value2 - Number, date or attribute of some type of number or date.
When one or both values are a set, the '=' operator is translated to SUBSET OF:
"a" = ["a", "b"]
is equivalent to"a" SUBSET OF ["a","b"]
, which returns true["a", "b"] = "a"
is also equivalent to"a" SUBSET OF ["a","b"]
, note that the arguments are switched. Because we have a set and a single value, there is only one way to interpret this with theSUBSET OF
function.["a"] = ["a", "b"]
is equivalent to["a"] SUBSET OF ["a","b"]
, which returns true["a", "b"] = ["a"]
is equivalent to["a", "b"] SUBSET OF ["a"]
, which returns false. (note that if "set1 = set2" returns true, it does not mean that "set2 = set1" will also return true)
To test if two sets are equal you could use the expression:
Code Block |
---|
L1 SUBSET OF L2 AND L2 SUBSET OF L1 |
Return type
- boolean
Examples
LESS
The operator '!=' compares two values and returns the boolean value TRUE if the left value is not equal to the right value and FALSE otherwise. |
Syntax
Code Block |
---|
value1 != value2 |
- value1 - Number, date or attribute of some type of number or date.
- value2 - Number, date or attribute of some type of number or date.
Return type
- boolean
Examples
...
bgColor | white |
---|
The operator '<' compares two values and returns the boolean value TRUE if the left value is smaller than the right value and FALSE otherwise. |
Syntax
Code Block |
---|
value1 < value2 |
- value1 - Number, date or attribute of some type of number or date.
- value2 - Number, date or attribute of some type of number or date.
Return type
- boolean
Examples
...
bgColor | white |
---|
LESS OR EQUAL
...
bgColor | white |
---|
GREATER
The operator '<=' compares two values and returns the boolean value TRUE if the left value is smaller than or equal to the right value and FALSE otherwise. |
Syntax
Code Block |
---|
value1 <= value2 |
- value1 - Number, date or attribute of some type of number or date.
- value2 - Number, date or attribute of some type of number or date.
Return type
- boolean
Examples
The operator '>' compares two values and returns the boolean value TRUE if the left value is greater than the right value and FALSE otherwise. |
Syntax
Code Block |
---|
value1 > value2 |
- value1 - Number, date or attribute of some type of number or date.
- value2 - Number, date or attribute of some type of number or date.
Return type
- boolean
Examples
...
bgColor | white |
---|
GREATER OR EQUAL
The operator '>=' compares two values and returns the boolean value TRUE if the left value is greater than or equal to the right value and FALSE otherwise. |
Syntax
Code Block |
---|
value1 >= value2 |
- value1 - Number, date or attribute of some type of number or date.
- value2 - Number, date or attribute of some type of number or date.
Return type
- boolean
Examples
...
bgColor | white |
---|
ANNUITY
This function is able to directly compute an annuity for you. An annuity is a terminating "stream" of fixed payments, i.e., a collection of payments to be periodically received over a specified period of time.
It is computed using this formula:
where
- J = monthly payment
- i = rate of interest
- n = number of terms
- T = loan amount
Syntax
Code Block |
---|
ANNUITY ( loan_amount , interest_rate , number_of_terms ) |
- loan_amount - The total currency amount that should be paid back.
- interest_rate - The interest rate as type percentage that should be paid on a loan (As a fraction, e.g. 5% = 0.05)
- number_of_terms - The number of terms as integer.
Return type
- number - The monthly payment.
Examples
ANNUITY | Computes an annuity. An annuity is a terminating "stream" of fixed payments. |
Functions
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
...