Functions

Every function is of form FCT-NAME(argument1, ...), expects one or more arguments, and returns a value.

In the following section, each function is listed, including the data structure and data type of each argument, and the return value. This is done by using form DataStructure<DataType>.

AVG

Description

Calculates the average on a set of numbers or event values

Signatures

AVG(Vector<Number/Event>)

AVG(GroupedScalar<any, Number/Event>)

AVG(GroupedVector<any, Number/Event>)


AVG(Vector<Number/Event>)

AVG(vector: Vector<Number/Event>): Scalar<Number>

Calculate the average as Scalar<any> from the given parameter.

Parameters

ParameterDescription

vector

A vector of type <Number/Event>

Returns

Returns the average as Scalar<Number>


AVG(GroupedScalar<any, Number/Event>)

AVG(group: GroupedScalar<any, Number/Event>): Scalar<Number>

Calculate the average as Scalar<any> from the given parameter.

Parameters

ParameterDescription

group

A GroupedScalar of type <any, Number/Event>

Returns

Returns the average as Scalar<Number>


AVG(GroupedVector<any, Number/Event>)

AVG(group: GroupedVector<any, Number/Event>): GroupedScalar<Number>

Calculate the average as GroupedScalar<any> from the given parameter.

Parameters

ParameterDescription

group

A GroupedVector of type <any, Number/Event>

Returns

Returns the average as Scalar<Number>


Examples

Retrieve the average of the GridPowerConsumption time series.

AVG($GridPowerConsumption)

SUM

Description

Calculates the sum on a set of numbers or event values

Signatures

SUM(Vector<Number/Event>)

SUM(GroupedScalar<any, Number/Event>)

SUM(GroupedVector<any, Number/Event>)


SUM(Vector<Number/Event>)

SUM(vector: Vector<Number/Event>): Scalar<Number>

Calculate the sum as Scalar<any> from the given parameter.

Parameters

ParameterDescription

vector

A vector of type <Number/Event>

Returns

Returns the sum as Scalar<Number>


SUM(GroupedScalar<any, Number/Event>)

SUM(group: GroupedScalar<any, Number/Event>): Scalar<Number>

Calculate the sum as Scalar<any> from the given parameter.

Parameters

ParameterDescription

group

A GroupedScalar of type <any, Number/Event>

Returns

Returns the sum as Scalar<Number>


SUM(GroupedVector<any, Number/Event>)

SUM(group: GroupedVector<any, Number/Event>): GroupedScalar<Number>

Calculate the sum as Scalar<any> from the given parameter.

Parameters

ParameterDescription

group

A GroupedVector of type <any, Number/Event>

Returns

Returns the sum as Scalar<Number>


Examples

Retrieve the sum of the GridPowerConsumption time series.

SUM($GridPowerConsumption)

MIN

Description

Extracts the minimum on a set of numbers or event values

Signatures

MIN(Vector<Number/Event>)

MIN(GroupedScalar<any, Number/Event>)

MIN(GroupedVector<any, Number/Event>)


MIN(Vector<Number/Event>)

MIN(vector: Vector<Number/Event>): Scalar<Number>

Extract the lowest value as Scalar<any> from the given parameter.

Parameters

ParameterDescription

vector

A vector of type <Number/Event>

Returns

Returns the lowest value as Scalar<Number>


MIN(GroupedScalar<any, Number/Event>)

MIN(group: GroupedScalar<any, Number/Event>): Scalar<Number>

Extract the lowest value as Scalar<any> from the given parameter.

Parameters

ParameterDescription

group

A GroupedScalar of type <any, Number/Event>

Returns

Returns the lowest value as Scalar<Number>


MIN(GroupedVector<any, Number/Event>)

MIN(group: GroupedVector<any, Number/Event>): Scalar<Number>

Extract the lowest value as Scalar<any> from the given parameter.

Parameters

ParameterDescription

group

A GroupedVector of type <any, Number/Event>

Returns

Returns the lowest value as Scalar<Number>


Examples

Retrieve the minimum of the GridPowerConsumption time series.

MIN($GridPowerConsumption)

MAX

Description

Extracts the maximum on a set of numbers or event values

Signatures

MAX(Vector<Number/Event>)

MAX(GroupedScalar<any, Number/Event>)

MAX(GroupedVector<any, Number/Event>)


MAX(Vector<Number/Event>)

MAX(vector: Vector<Number/Event>): Scalar<Number>

Extract the highest value as Scalar<any> from the given parameter.

Parameters

ParameterDescription

vector

A vector of type <Number/Event>

Returns

Returns the highest value as Scalar<Number>


MAX(GroupedScalar<any, Number/Event>)

MAX(group: GroupedScalar<any, Number/Event>): Scalar<Number>

Extract the highest value as Scalar<any> from the given parameter.

Parameters

ParameterDescription

group

A GroupedScalar of type <any, Number/Event>

Returns

Returns the highest value as Scalar<Number>


MAX(GroupedVector<any, Number/Event>)

MAX(group: GroupedVector<any, Number/Event>): Scalar<Number>

Extract the highest value as Scalar<any> from the given parameter.

Parameters

ParameterDescription

group

A GroupedVector of type <any, Number/Event>

Returns

Returns the highest value as Scalar<Number>


Examples

Retrieve the maxiumum of the GridPowerConsumption time series.

MAX($GridPowerConsumption)

COUNT

Description

Counts the number of entries on a vector, grouped scalar, or grouped vector

Signatures

COUNT(Vector<Number/Event>)

COUNT(GroupedScalar<any, Number/Event>)

COUNT(GroupedVector<any, Number/Event>)


COUNT(Vector<Number/Event>)

COUNT(vector: Vector<Number/Event>): Scalar<Number>

Count the entries of the given Vector<Number/Event>.

Parameters

ParameterDescription

vector

A vector of type <Number/Event>

Returns

Returns how many elements are within the given vector as Scalar<Number>


COUNT(GroupedScalar<any, Number/Event>)

COUNT(group: GroupedScalar<any, Number/Event>): Scalar<Number>

Count the entries of the given GroupedScalar<any, Number/Event>.

Parameters

ParameterDescription

group

A GroupedScalar of type <any, Number/Event>

Returns

Returns how many elements are within the given group as Scalar<Number>


COUNT(GroupedVector<any, Number/Event>)

COUNT(group: GroupedVector<any, Number/Event>): Scalar<Number>

Count the entries of the given GroupedVector<any, Number/Event>.

Parameters

ParameterDescription

group

A GroupedVector of type <any, Number/Event>

Returns

Returns how many elements are within the given group as Scalar<Number>


Examples

Count the elements within the GridPowerConsumption time series.

COUNT($GridPowerConsumption)

SORT

Description

Sorts the entries of the given parameter in ascending order.

Signatures

SORT(Scalar<any>)

SORT(Vector<any>)

SORT(GroupedScalar<any, any> [, Scalar<Text>])

SORT(GroupedVector<any, any> [, Scalar<Text>])


SORT(Scalar<any>)

SORT(scalar: Scalar<any>): Scalar<any>

Sort the entries of the given Scalar<any> in ascending order.

Parameters

ParameterDescription

scalar

A scalar of type any

Returns

Returns the given scalar sorted in ascending order as type Scalar<any>.


SORT(Vector<any>)

SORT(vector: Vector<any>): Vector<any>

Sort the entries of the given Vector<any> in ascending order.

Parameters

ParameterDescription

vector

A vector of type any

Returns

Returns the given vector sorted in ascending order as type Vector<any>.


SORT(GroupedScalar<any, any> [, Scalar<Text>])

SORT(group: GroupedScalar<any, any> [, by: Scalar<Text>]): GroupedScalar<any, any>

Sort the entries of the given GroupedScalar<any, any> in ascending order by values.

Parameters

ParameterDescription

group

A GroupedScalar of type <any, any>

by

The by parameter is optional.

Specifies by which attribute of the vector it should be sorted.Allowed values are byGroupKey and byGroupValue.

Default is byGroupValue.

Returns

Returns the given group sorted by the specified property in ascending order as type GroupedScalar<any, any>.


SORT(GroupedVector<any, any> [, Scalar<Text>])

SORT(group: GroupedVector<any, any> [, by: Scalar<Text>]): GroupedVector<any, any>

Sort the entries of the given GroupedVector<any, any> in ascending order by values.

Parameters

ParameterDescription

group

A GroupedVector of type <any, any>

by

The by parameter is optional.

Specifies by which attribute of the vector it should be sorted.Allowed values are byGroupKey and byGroupValue.

Default is byGroupValue.

Returns

Returns the given group sorted by the specified property in ascending order as type GroupedScalar<any, any>.

Examples

Sort GridPowerConsumption in ascending order.

SORT($GridPowerConsumption)

Sort GroupedByDevicePowerConsumption in ascending order by event

SORT($GroupedByDevicePowerConsumption, byGroupKey)

REVERSE

Description

Reverses the entries. So if applying on ascending ordered data, you would get a descending ordered data set.

Signatures

REVERSE(Scalar<any>)

REVERSE(Vector<any>)

REVERSE(GroupedScalar<any, any>)

REVERSE(GroupedVector<any, any>)


REVERSE(Scalar<any>)

REVERSE(scalar: Scalar<any>): Scalar<any>

Reverse the order of the given Scalar<any>

Parameters

ParameterDescription

scalar

A scalar of type any

Returns

Returns the given scalar in reversed order with type Scalar<any>

REVERSE(Vector<any>)

REVERSE(vector: Vector<any>): Vector<any>

Reverse the order of the elements in the given Vector<any>

Parameters

ParameterDescription

vector

A vector of type any

Returns

Returns the given vector in reversed order with type Vector<any>


REVERSE(GroupedScalar<any, any>)

REVERSE(group: GroupedScalar<any,any>): GroupedScalar<any,any>

Reverse the order of the elements in the given GroupedScalar<any, any>

Parameters

ParameterDescription

group

A GroupedScalar of type <any, any>

Returns

Returns the given group in reversed order with type GroupedScalar<any, any>.


REVERSE(GroupedVector<any, any>)

REVERSE(group: GroupedVector<any,any>): GroupedVector<any,any>

Reverse the order of the elements in the given GroupedVector<any, any>

Parameters

ParameterDescription

group

A GroupedVector of type <any, any>

Returns

Returns the given group in reversed order with type GroupedVector<any, any>.

Examples

Reverse the elements in the GridPowerConsumption Vector.

REVERSE($GridPowerConsumption)

SUBSET

Description

Extracts a subset of elements from a given Vector.

Signatures

SUBSET(Vector<Any>, Scalar<Number>)

SUBSET(Vector<any>, Scalar<Number>, Scalar<Number>)

SUBSET(Vector<Event>, Scalar<Time>)

SUBSET(Vector<Event>, Scalar<Time>, Scalar<Time>)


SUBSET(Vector<Any>, Scalar<Number>)

Extract the first or last x entries.

SUBSET(vector: Vector<Any>, x: Scalar<Number>): Vector<Any>

Parameters

ParameterDescription

vector

A vector of type any.

x

A positive or negative number. When x is a positive number it starts to extract the number of entries stated in param2 from the beginning, when param2 is a negative number it starts to extract the number of entries stated in param2 from the end of the vector.

Returns

Returns a Vector of type any.


SUBSET(Vector<any>, Scalar<Number>, Scalar<Number>)

SUBSET(vector: Vector<Any>, x: Scalar<Number>, y: Scalar<Number>): Vector<Any>

Parameters

ParameterDescription

vector

A vector of type any.

x

Position from which to start extracting elements. If negative, then position is counted from the end of the vector.

y

Position until which to extract elements. If negative, then position is counted from the end of the vector.

SUBSET(Vector<Event>, Scalar<Time>)

SUBSET(vector: Vector<Event>, start: Scalar<Time>): Vector<Event>

Extract entries from time start until the latest event (left argument is excluding, right is including)

Parameters

ParameterDescription

vector

A vector of type Event.

start

The start time from which to start extracting entries until the latest.

Returns

A Vector of type Event.


SUBSET(Vector<Event>, Scalar<Time>, Scalar<Time>)

SUBSET(vector: Vector<Event>, start: Scalar<Time>, end: Scalar<Time>): Vector<Event>

Extract entries from time start until time end (left argument is excluding, right is including the time border)

Parameters

ParameterDescription

vector

A vector of type Event

start

The start time from which to start extracting entries. (Excluded)

end

The end time until which to extract entries. (Included)

Returns

A Vector of type Event.

Examples

Extract the last entry from the vector GridPowerConsumption.

SUBSET($GridPowerConsumption, -1)

Extract all events from zero hour (midnight) until now.

SUBSET($GridPowerConsumption, lastZeroHour)

Extract all events 2 days ago until 1 day ago.

SUBSET($GridPowerConsumption, now-2d, now-1d)

FILTER

Description

Filter data on a vector, grouped scalar or grouped vector, by comparing with a threshold. Only data which fulfills that boolean condition is kept.

Signatures

Filter(Vector<Number/Event>, Scalar<Text>, Scalar<Number/Event>)

Filter(GroupedScalar<any, Number/Event>, Scalar<Text>, Scalar<Number/Event>)

Filter(GroupedVector<any, Number/Event>, Scalar<Text>, Scalar<Number/Event>)

Filter(Vector<Number/Event>, Scalar<Text>, Scalar<Number/Event>)

FILTER(vector: Vector<Number/Event>, 
       comparisonSymbol: Scalar<Text>, 
       threshold: Scalar<Number/Event>): Vector<Device/Event>

Filter data in the given vector by comparing with the threshold.

Parameters

ParameterDescription

vector

A vector of type Number or Event, which is compared to a threshold

comparisonSymbol

The comparison symbol. One of: <, <=, =, !=, >=, >

threshold

A threshold which is a scalar of Number or Event.

Returns

Vector of same type as from the first function parameter, with filtered data.

Examples

Filter events, so that only values > 1000 are kept in the vector.

FILTER($GridPowerConsumption, '>', 1000)

Filter(GroupedScalar<any, Number/Event>, Scalar<Text>, Scalar<Number/Event>)

FILTER(groupedScalar: GroupedScalar<any, Number/Event>, 
       comparisonSymbol: Scalar<Text>, 
       threshold: Scalar<Number/Event>): GroupedScalar<any, Number/Event>

Filter data in the given grouped scalar by comparing with the threshold. Empty groups are removed from the grouped scalar.

Parameters

ParameterDescription

groupedScalar

A grouped scalar of type Number or Event, which is compared to a threshold

comparisonSymbol

The comparison symbol. One of: <, <=, =, !=, >=, >

threshold

A threshold which is a scalar of Number or Event.

Returns

Grouped scalar of same type as from the first function parameter, with filtered data.

Examples

Filter events in the grouped scalar, so that only values > 1000 are kept in the vector.

FILTER(MIN(GROUP_BY_DEVICE($PowerConsumption)), '!=', 0)

Filter(GroupedVector<any, Number/Event>, Scalar<Text>, Scalar<Number/Event>)

FILTER(groupedVector: GroupedVector<any, Number/Event>, 
       comparisonSymbol: Scalar<Text>, 
       threshold: Scalar<Number/Event>): GroupedVector<any, Device/Event>

Filter data in the given grouped vector by comparing with the threshold. Empty groups are removed from the grouped vector.

Parameters

ParameterDescription

groupedVector

A grouped vector of type Number or Event, which is compared to a threshold

comparisonSymbol

The comparison symbol. One of: <, <=, =, !=, >=, >

threshold

A threshold which is a scalar of Number or Event.

Returns

Grouped vector of same type as from the first function parameter, with filtered data.

Examples

Filter events, so that only values > 1000 are kept in the grouped vector.

FILTER(GROUP_BY_DEVICE($PowerConsumption), '<=', 200)

GROUP_BY_DEVICE

Description

Converts vector to a grouped vector by grouping by devices. I.e. each device has its own list of events.

Signatures

GROUP_BY_DEVICE(Vector<Event>)


GROUP_BY_DEVICE(Vector<Event>)

GROUP_BY_DEVICE(vector: Vector<Event>): GroupedVector<Device,Event>

Groups the events in the given vector by deviceId.

Parameters

ParameterDescription

vector

A vector of type Event

Returns

A GroupedVector of type <Device,Event>.

Examples

Group the events in the GridPowerConsumption vector by device id.

GROUP_BY_DEVICE($GridPowerConsumption)

GROUP_BY_TIME

Description

Converts vector to a grouped vector, by gouping by timespans, so that we have a list of events per timespan. The timespan either is fixed on the latest event, or can be fixed on another time if specified.

Signatures

GROUP_BY_TIME(Vector<Event>, Scalar<Timespan>)

GROUP_BY_TIME(Vector<Event>, Scalar<Timespan>, Scalar<Time>)


GROUP_BY_TIME(Vector<Event>, Scalar<Timespan>)

GROUP_BY_TIME(vector: Vector<Event>, timespan: Scalar<Timespan>): GroupedVector<Time,Event>

Groups the events in the given vector in spans defined by timespan, starting from the latest event.

Parameters

ParameterDescription

vector

A vector of type Event

timespan

A timespan in which the events should be grouped

Returns

A GroupedVector of type <Time, Event>.

GROUP_BY_TIME(Vector<Event>, Scalar<Timespan>, Scalar<Time>)

GROUP_BY_TIME(vector: Vector<Event>, timespan: Scalar<Timespan>, time: Scalar<Time>): GroupedVector<Time,Event>

Group the vector in the given timespans starting at the given time.

Parameters

ParameterDescription

vector

A vector of type Event

timespan

A timespan in which the events should be grouped

time

The time form which we want to start grouping.

Returns

A GroupedVector of type <Time, Event>.

Examples

Group events in 1h spans starting from latest event

GROUP_BY_TIME($GridPowerConsumption, 1h)

Group events in 1d spans on full day spans (i.e. 00:00-23:59)

GROUP_BY_TIME($Produced, 1d, lastZeroHour)

Last updated

© 2023 MOOST AG