# List of functions

## Data types

### null value

`null` is a non-value, it's a placeholder for a data value that is not known or specified. Some functions can receive `null` as a parameter and in some conditions they may also return `null`.

### Simple types

All simple types can be used as function parameters.

## Functions and operators

The following table lists and describes the different functions and operators you can use.

Tip: In the table, the type indicates the types that are defined for use with a given function. When you can use more than one type, the | symbol indicates that you can use one type or the other.

Function Type Description Expression-based support
Abs

Logic

(At instant derivation)

Integer Abs(Integer value)

Returns the absolute value of an Integer value.

If the value is not negative, the value is returned. If the value is negative, the negation of the value is returned.

If the value is Integer MIN_VALUE, since this value cannot be represented as a positive Integer, the result is that same value that is negative. Decimal Abs(Decimal value)

Returns the absolute value of a Decimal value

If the value is not negative, the value is returned. If the value is negative, the negation of the value is returned.

If the value is NaN the result is NaN. If the value is infinite the result is positive infinite.

Logic

(At instant derivation)

Returns the sum of the specified integer values.

If at any time during the computation, the sum becomes greater than Integer MAX_VALUE or lower than MIN_VALUE, then the value of the final result is unpredictable. Operator +

Returns the sum of the specified Decimal values.

• Returns the Concatenation of second string at the end of first string. If other values are specified, then they are concatenated at the end of the result.
• If one of the specified strings is `null`, the null string is concatenated.

Returns a new Instant value computed from adding the specified Durations to the start Instant.

Returns an Instant value computed from adding the specified Durations to the start Instant.

Interval Add(Interval interval , CalendarDuration duration, CalendarDuration... duration)

Returns an Interval value computed from adding the specified Durations to the start and the end instants of the specified Interval.

Returns an Interval value computed from adding the specified Durations to the start and the end instants of the specified Interval.

Returns a Duration value based on the sum of the specified Duration values.

And
Logic
(At instant derivation)

Boolean And(Boolean first, Boolean second, Boolean... add more values as needed)

Returns the logical conjunction of the specified inputs.

• Returns `true` if and only if all values are `true` .
• Returns `false` if one of the values is `false`.
• Returns ` null ` if some values are ` null ` and no other is ` false ` . Operator &&
Consolidation
(Structural aggregation or temporal derivation)

Boolean And(Boolean value)

Returns the logical conjunction of the input:
• Returns `true` if and only if there are no values at `false`.
• Returns `false` if one of the values is `false`. Average

Consolidation

(Structural aggregation or temporal derivation)

Type Average(Type value)

Where Type is either Integer, Decimal, Instant, Duration.

• Returns the average of the values.
• If there is no value, returns `null`. Average weighted

Consolidation

(Structural aggregation or temporal derivation)

Type Average weighted (Type value,[Decimal | Integer] weight)

Where Type is either Integer, Decimal, Instant, Duration.

• Returns the weighted average of the values, i.e. (∑ value * weight) / (∑ weight)
• If there is no value, or no weight or (∑ weight) == 0, returns `null`. Baseline

Consolidation

(temporal derivation)

Baseline(Type) Baseline(Type value, Rythm typicalRythm, Integer history)

Where Type is either Decimal, Duration.

Returns a  Baseline of the value, using data of the history, to compute the typical-Rhythm. Baseline - old

Consolidation

(temporal derivation)

Baseline - old(Type) Baseline - old(Type Value, Rythm granularity, Integer history).

Where Type is either Integer, Decimal, Duration.

Returns old baseline (for compatibilities) of the value, using data of the history with a granularity aggregation. Begin

Logic

(At instant derivation)

Instant Begin(Interval value)

• Returns the start Instant of the specified Interval.
• If the value is `null`, returns `null`. Ceil

Logic

(At instant derivation)

Integer Ceil(Decimal value)

Returns the smallest Integer value that is greater than or equals to the specified Decimal value.

If the value is:

• Greater than Integer MAX_VALUE, the result is Integer MAX_VALUE.
• Lower than Integer MIN_VALUE, the result is Integer MIN_VALUE.
• Nan or Zero, the result is 0. Classifier from baseline - old

Logic

(At instant derivation)

Classifier Classifier from baseline - old(Type value, Baseline - old(Type) baseline,Baseline threshold multiplier - old multiplier).

Where Type is either Integer, Decimal, Duration.

Returns the classifier that suits the value from the baseline with the multiplier. Classifier from thresholds

Logic

(At instant derivation)

Classifier Classifier from thresholds(Type value, Thresholds(Type to Classifier) thresholds)

Where Type is either Integer, Decimal, Duration, Instant, String.

Returns the classifier that suits the value on the thresholds. Classifier from thresholds - old

Logic

(At instant derivation)

Classifier Classifier from thresholds - old(Type value, Threshold levels - old(Type) thresholdLevels)

Where Type is either Integer, Decimal, Duration, Instant.

Returns the old classifier (for compatibilities) that suits the value on the thresholdLevels. Contains

Logic

(At instant derivation)

Boolean Contains(String text, String fragment)

Returns `true` if both strings are not `null` and the text string contains the fragment string. ContainsCaseInsensitive

Logic

(At instant derivation)

Same as Contains but ignoring case differences. Correlation coefficient

Consolidation

(Structural aggregation or temporal derivation)

Double Correlation coefficient([Integer | Decimal] x, [Integer | Decimal y])

Returns ( n * ∑(x*y) - (∑x) * (∑y) ) / ( √ ( n * ∑x² - (∑x)² ) * √ ( n * ∑y² - (∑y)² ) ) where n is the number of values.

if no value, returns null. Count

Consolidation

(Structural aggregation or temporal derivation)

Integer Count(Type value)

Returns

• the number of not `null` value.
• 0 if there is no value.

Possible types are:

Simple types: Duration, CalendarDuration, Integer, Decimal, Instant, Interval, Boolean.

Complex types: Classifier, Instance, Relation, Baseline, Forecast. CreateInterval

Logic

(At instant derivation)

Interval CreateInterval(Instant start, Instant end)

Returns a closed-open Interval based on the specified Instants.

• If one of the Instants is `null`, the result is `null`.
• If end Instant is not greater than start Instant, an error is raised. Interval CreateInterval(Instant start, Instant end, Boolean includeStart, Boolean includeEnd)

Returns an Interval based on the specified Instants. Interval boundaries are included or not based on includeStart and includeEnd value.

• If one of the Instants is `null`, the result is `null`.
• If end Instant is not greater than start instant, an error is raised.
Interval CreateInterval(Instant reference, CalendarDuration duration, Boolean referenceAtEnd)

Returns a closed-open Interval based on the specified Instant and duration.

• If reference or duration is `null`, the result is `null`.
• If referenceAtEnd is `true` then, reference is the end instant of the Interval and the start instant is calculated by subtracting the duration from the end.
• If referenceAtEnd is `false` then, reference is the beginning instant of the Interval and the end instant is calculated by adding the duration to the start.

Interval CreateInterval(Instant reference, CalendarDuration duration, Boolean referenceAtEnd, Boolean includeStart , Boolean includeEnd )

Returns an Interval based on the specified Instant and duration. Interval boundaries are included or not based on includeStart and includeEnd value.

• If reference or duration is `null`, the result is `null`.
• If referenceAtEnd is `true` then, reference is the end instant of the Interval and the start instant is calculated by subtracting the duration from the end.
• If referenceAtEnd is `false` then, reference is the start instant of the Interval and the end instant is calculated by adding the duration to the start.

Interval CreateInterval(Interval interval, Boolean startIncluded, Boolean endIncluded),

• Returns an Interval based on the specified Interval. Interval boundaries are included or not based on includeStart and includeEnd value.
• If interval is `null,` the result is `null`.
Div

Logic

(At instant derivation)

Decimal Div(Type dividend, [Decimal | Integer] divisor)

Where Type is either Integer, Decimal or Duration

Returns the Decimal result of dividend divided by divisor.

• If divisor is zero and dividend is zero, returns NaN.
• If the only divisor is zero returns positive infinity if dividend is greater than zero, or returns negative infinity if dividend is lower than zero. Operator /

Decimal Div(Duration dividend, Duration divisor)

• Returns the result of the division of the amount of milliseconds of the specified Durations.
• If both dividend and divisor has an amount of zero, returns NaN
• If only divisor is zero, returns positive infinity if dividend amount is greater than zero, or returns negative infinity if dividend amount is lower than zero.
Duration

Logic

(At instant derivation)

Duration Duration(Instant start, Instant end)

• Returns the duration of the Interval specified by start Instant and end Instant.
• If one of the Instants is `null` the functions returns `null`. Duration Duration(Interval value)

• Returns the duration of the specified Interval.
• If value is `null` the function returns `null`.
End

Logic

(At instant derivation)

Instant End(Interval value)

• Returns the end Instant of the specified Interval.
• If the value is `null`, returns `null`. EndsWith

Logic

(At instant derivation)

Boolean EndsWith(String first, String second)

Returns `true` if both strings are not `null` and the first string ends with the second one. EndsWithCaseInsensitive

Logic

(At instant derivation)

Same as EndsWith but ignoring case differences. Equals

Logic

(At instant derivation)

Boolean Equals(Type Input1, Type Input2)

Returns `true`  if the first input is equal to the second input.

• If both inputs are `null`, returns `true`.
• If only one of the inputs is `null`, returns `null`.

The two inputs must be of the same type. Possible types are:

• Simple types: Duration, CalendarDuration, Integer, Decimal, Instant, Interval, Boolean.
• Complex types: Classifier, Instance, Relation, Baseline, ThresholdLevel, BaselineThresholdMultiplier.
• For String, see String functions Operator ==
EqualsCaseInsensitive

Logic

(At instant derivation)

Same as Equals but ignoring case differences for String type only. First

Consolidation

(Structural aggregation or temporal derivation) Temporal derivation should not be used.

Type First(Comparable comparator, Type value)

Where Comparable is of type Boolean, Classifier, Decimal, Duration, Instant, Integer or String.
Where Type is

• Either a simple type: Duration, CalendarDuration, Integer, Decimal, Instant, Interval, Boolean.
• Or a complex type: Classifier, Instance, Relation, Baseline, ThresholdLevel, BaselineThresholdMultiplier.
• Returns the fist value following the comparator order at the same time range.
• If no value, returns `null`. Time configurations should represent an Instant. Floor

Logic

(At instant derivation)

Integer Floor(Decimal value)

Returns the largest Integer value that is less than or equal to the specified Decimal value.

If the value is:

• Greater than Integer MAX_VALUE, the result is Integer MAX_VALUE.
• Lower than Integer MIN_VALUE, the result is Integer MIN_VALUE.
• Nan or Zero, the result is 0. Forecast (Linear regression)

Consolidation

(Temporal derivation)

Forecast(Type) Forecast (Linear regression)(Type value, Duration lastDuration, Integer numberOfForecast)

Where Type is either Integer, Decimal, Duration.

Returns the Forecast of the value using lastDuration of data to forecast numberOfForcast times. Forecast Classifier

Logic

(At instant derivation)

Forecast(ClassifierForecast Classifier(Forecast(Type) forecast, Thresholds(Type to Classifier) thresholds)

Where Type is either Integer, Decimal, Duration.

Returns the evaluation of the forecast against the thresholds. GreaterThan

Logic

(At instant derivation)

Boolean GreaterThan(Type input1, Type input2)

Determines if the first input is greater than the second input.

If one of the inputs is `null`, returns `null`.

The two inputs must be of the same type. Possible types are:

• Simple types: Integer, Decimal, Duration, Instant, Boolean, String.
• Complex types : Classifier. Operator >
GreaterThanOrEquals

Logic

(At instant derivation)

Boolean GreaterThanOrEquals(Type input1, Type input2)

Returns `true` if the first input is greater than or equals the second input.

• If both inputs are `null`, returns `true`.
• If only one of the inputs is `null`, returns `null`.

The two inputs must be of the same type. Possible types are:

• Simple types: Integer, Decimal, Duration, Instant, Boolean, String.
• Complex types : Classifier Operator >=
IfThenElse

Logic

(At instant derivation)

Type IfThenElse(Boolean condition, Type thenValue, Type elseValue)

Evaluates the condition and returns thenValue if condition is `true` or elseValue otherwise.

Both thenValue and elseValue must be of the same type. Possible types are:

Simple types: Duration, CalendarDuration, Integer, Decimal, Instant, Interval, Boolean, String.

Complex types: Classifier, Instance, Relation.

Using the IfThenElse function is equivalent to using this syntax:

```If condition
Then thenValue
Else elseValue
End``` In

Logic

(At instant derivation)

Boolean In(AnyType valueToTest, AnyType... values)

• Returns `true` if one of the specified values equals valueToTest.
• If values is `null`, returns `false`. Intersection

Logic

(At instant derivation)

Interval Intersection(Interval first, Interval second)

• Returns the interval representing the intersection of the two specified intervals, or `null` if the two Intervals do not intersect.
• If one of the values is `null` the result is `null`. Intersects

Logic

(At instant derivation)

Boolean Intersects(Interval interval, Instant instant)

• Returns `true` if the instant is included in the Interval.
• If interval or instant is `null` returns `null`. Boolean Intersects (Instant instant, Interval interval)

• Returns `true` if the instant is included in the Interval.
• If interval or instant is `null` returns `null`.

Boolean Intersects(Interval first , Interval second)

• Returns `true` if the two specified intervals intersect.
• If one of the intervals is `null` returns `null`.
Inverse

Logic

(At instant derivation)

Decimal Inverse([Decimal | Integer] value)

Returns the multiplicative inverse or reciprocal of the specified value, denoted by 1/value or value-1. IsNaN

Logic

(At instant derivation)

Boolean IsNaN(Decimal value)

Returns `true` if the specified value is a Not-A-Number (NaN) value, `false` otherwise. IsNull

Logic

(At instant derivation)

Boolean IsNull(AnyType input)

Returns `true` if the specified value is `null`. IsNumber

Logic

(At instant derivation)

Boolean IsNumber(Decimal value)

Returns `true` if the specified value is a number(not NaN) value, `false` otherwise. IsNotNull

Logic

(At instant derivation)

Boolean IsNotNull(AnyType input)

Returns `true` if the specified value is not `null`. Last

Consolidation

(Structural aggregation or temporal derivation) Temporal derivation should not be used.

Type Last(Comparable comparator, Type value)

Where Comparable is of type Boolean, Classifier, Decimal, Duration, Instant, Integer or String.
Where Type is

• Either a simple type: Duration, CalendarDuration, Integer, Decimal, Instant, Interval, Boolean.
• Or a complex type: Classifier, Instance, Relation, Baseline, ThresholdLevel, BaselineThresholdMultiplier.
• Returns the last value following the comparator order at the same time range.
• If no value, returns `null`. Time configurations should represent an Instant. LowerThan

Logic

(At instant derivation)

Boolean LowerThan(Type input1, Type input2)

Determines if the first input is lower than the second input.

If one of the inputs is `null` returns `null`.

The two inputs must be of the same type. Possible types are:

• Simple types: Integer, Decimal, Duration, Instant, Boolean, String.
• Complex types : Classifier. Operator <
LowerThanOrEquals

Logic

(At instant derivation)

Boolean LowerThanOrEquals(Type input1, Type input2)

Determines if the first input is lower than or equal to the second input.

• If both inputs are `null` returns `true`.
• If only one of the inputs is `null` returns `null`.

The two inputs must be of the same type. Possible types are:

• Simple types: Integer, Decimal, Duration, Instant, Boolean, String.
• Complex types: Classifier Operator <=
Maximum (expression)
Logic
(At instant derivation)

Comparable Maximum (expression) (Comparable first, Comparable ... add more values as needed)

Where Comparable is of type Boolean, Classifier, Decimal, Duration, Instant, Integer or String.

• Returns the greatest value of the specified Comparable values. At least one value must be provided.
• If all values are `null`, returns `null`. Maximum

Consolidation

(Structural aggregation or temporal derivation)

Comparable Maximum(Comparable value)

Where Comparable is of type Boolean, Classifier, Decimal, Duration, Instant, Integer or String.

• Returns the greatest value.
• If no value, returns `null`. Minimum (expression)
Logic
(At instant derivation)

Comparable Minimum (expression)(Comparable first, Comparable... add more values as needed)

Where Comparable is of type Boolean, Classifier, Decimal, Duration, Instant, Integer or String.

• Returns the smallest value of the specified Comparable values. At least one value must be provided.
• If all values are `null`, returns `null`. Minimum

Consolidation

(Structural aggregation or temporal derivation)

Comparable  Minimum (Comparable value)

Where Comparable is of type Boolean, Classifier, Decimal, Duration, Instant, Integer or String.

• Returns the smallest value.
• If all values are `null`, returns `null`. Modulo

Logic

(At instant derivation)

[Integer|Decimal] Modulo([Integer|Decimal] first, [Integer|Decimal] second)

Returns the remainder of the division of first by second. Operator %
Multiply

Logic

(At instant derivation)

[Integer|Decimal] Multiply([Integer|Decimal] first, [Integer|Decimal] second, [Integer|Decimal]... add more values as needed)

Returns the value of the multiplication of the specified values:

• If one of the values is NaN returns NaN.
• If one of the values is infinite and another is 0 the result is NaN. Operator *

Duration Multiply([Decimal | Integer] count, Duration duration)

Returns a duration whose amount is the specified Duration amount multiplied by count.

Duration Multiply(Duration duration, [Decimal | Integer] count)

Returns a duration whose amount is the specified duration amount multiplied by count.

Not
Logic
(At instant derivation)

Boolean Not(Boolean value)

Returns the negation of the specified input. If the input is `null`, `null` is returned. Unary Operator !
NotEquals

Logic

(At instant derivation)

Boolean NotEquals(Type Input1, Type Input2)

Determines if the first input is not equal to the second input.

The two inputs must be of the same type. Possible types are:

• Simple types: Duration, CalendarDuration, Integer, Decimal, Instant, Interval, Boolean.
• Complex types: Classifier, Instance, Relation, Baseline, ThresholdLevel, BaselineThresholdMultiplier.
• String see String functions Operator !=
NotEqualsCaseInsensitive

Logic

(At instant derivation)

Same as NotEquals but ignoring case differences for String type only. Opposite

Logic

(At instant derivation)

Decimal Opposite(Decimal value)

Returns the opposite value of the specified input

If the value is:

• NaN the result is NaN.
• Positive infinity, the result is negative infinity.
• Negative infinity, the result is positive infinity. Unary Operator -

Integer Opposite(Integer value)

Returns the opposite value of the specified input

If the value is:

• Integer MAX_VALUE returns -(Integer MAX_VALUE).
• Integer MIN_VALUE, since this value cannot be represented as a positive Integer, the result is that same value that is negative.

Duration Opposite(Duration input)

Returns the opposite value of the specified input.

Or
Logic
(At instant derivation)

Boolean Or(Boolean first, Boolean second, Boolean... add more values as needed)

Returns the logical disjunction (inclusive or) of the specified inputs

• Returns `false` if and only if all values are `false` .
• Returns `true `if one of the values if `true`.
• Returns ` null `  if some values are ` null ` and no other is ` true ` . Operator ||
Consolidation
(Structural aggregation or temporal derivation)

Boolean Or(Boolean value)

Returns the logical disjunction of the input.
• Returns `true` if one of the values is `true`.
• Returns `false` if and only if there is no true value. Overlap

Consolidation

(Structural aggregation or temporal derivation)

Interval Overlap(Inverval value)

• Returns the Interval that Overlap all the values.
• If no overlap, returns null. Interval Overlap(Instant value)

• Returns the Interval [ value ; value + 1ms ] if all values are the same.
• Else, returns `null`.
Percentile

Consolidation

(Structural aggregation or temporal derivation)

Decimal Percentile([Integer|Decimal|Duration] value, Decimal percentile) percentile should be less or equals than 100.0 and greater or equals than 0.0 and should not change.

Returns the percentileth  of values.

if there is no value or no percentile, returns NaN. Prefix

Logic

(At instant derivation)

String Prefix(String text, String prefixes...)

• Returns the first prefix for which text starts with.
• Returns `null`:
• If text is `null.`
• No prefix is specified.
• None of the prefixes match the start of text. Quotient

Logic

(At instant derivation)

Decimal Quotient(Decimal dividend, Decimal divisor)

Mimics the euclidian division for Decimal values.

Computes the division of dividend by divisor and then returns the largest Decimal value that is less than or equals to this result and is equal to a mathematical integer.

If the result of the division is NaN or infinite then returns the result of the division. Integer Quotient(Integer dividend, Integer divisor)

Returns the result of the euclidian division of dividend by divisor:

• If divisor is zero and dividend is zero an error is raised.
• If only divisor is zero returns Integer MAX_VALUE if dividend is greater than zero, or returns Integer MIN_VALUE if dividend is lower than zero.
Ratio

Consolidation

(Structural aggregation or temporal derivation)

Decimal Ratio(Boolean value)

• Returns the ratio number of `true` value/number of values.
• If no value, returns `NaN`. Round

Logic

(At instant derivation)

Integer Round(Decimal value)

Returns the closest Integer value to the specified decimal value.

If the value is:

• Greater than Integer MAX_VALUE, the result is Integer MAX_VALUE.
• Lower than Integer MIN_VALUE, the result is Integer MIN_VALUE.
• Nan or Zero, the result is 0 Standard deviation

Consolidation

(Structural aggregation or temporal derivation)

Decimal Standard deviation([Integer|Decimal] value)

• Returns √ ( ∑value² - ((∑value)² / n) ) / ( n - 1 ) where n is the number of values.
• if no value, returns` null`. Duration Standard deviation(Duration value)

• Returns √ ( ∑value² - ((∑value)² / n) ) / ( n - 1 ) where n is the number of values.
• if no value, returns null.
StartsWith

Logic

(At instant derivation)

Boolean Starts With(String, String)

Returns `true` if both strings are not `null` and the first string starts with the second one. StartsWithCaseInsensitive

Logic

(At instant derivation)

Same as Starts With but ignoring case differences. Subtract

Logic

(At instant derivation)

[Integer|Decimal] Subtract([Integer | Decimal] input1, [Integer | Decimal] input2)

Returns the [Integer | Decimal] value of input1 - input2. Operator -

Duration Subtract(Duration first, Duration second)

Returns the Duration value of first - second.

Instant Subtract(Instant start, CalendarDuration duration)

Returns an Instant value computed from removing the specified duration to the start Instant.

Instant Subtract(Instant start, Duration duration)

Returns an Instant value computed from removing the specified duration to the start Instant.

Interval Subtract(Interval start, CalendarDuration duration)

Returns an Interval value computed from removing the specified duration to the start and the end instants of the specified Interval.

Interval Subtract(Interval interval, Duration duration)

Returns an Interval value computed from removing the specified duration to the start and the end instants of the specified Interval.

Sum

Consolidation

(Structural aggregation or temporal derivation)

Decimal Sum(Decimal value)

• Returns the sum of the specified values.
• If all values are `null`, returns `0.0`. Integer Sum(Integer value)

Returns the sum of the specified integer values:

• If at any time during the computation, the sum becomes greater than Integer MAX_VALUE or lower than MIN_VALUE, then the value of the final result is unpredictable.
• If all values are `null`, returns `0`.

Duration Sum(Duration value)

• Returns the sum of the specified values.
• If all values are `null`, returns `0s`.
Thresholds from baseline
Logic
(At instant derivation)

Thresholds(Type to ClassifierThresholds from baseline(Baseline(Type) baseline, Dispersion Multipliers(Classifier) multipliers)

Where Type is either Decimal, Duration.

Returns the thresholds computed by adding the baseline average to the product of average standard deviation by multipliers.

See How to configure new Baseline and Thresholds.Classifier from thresholds Xor
Logic
(At instant derivation)

Boolean Xor(Boolean first, Boolean second)

• Returns the exclusive disjunction (exclusive or) of the specified booleans.
• If one of the values is `null`, the result is `null`. Operator ^