Series Functions
This page outlines series functions you can invoke using NetScript.
series along (c1 [desc](, c2 [desc])) [foreach ([p1(, p2)])]
- This is a series decoration. Rather than change the input data, it declares that the input data is logically ordered according to the given collation (
c1
,c2
…) within each partition as defined by distinct tuples of values ofp1
,p2
…
(required) Collation is specified byalong
and must have at least oneinput
.c2
and beyond are used only in the case of ties. - The (optional) partition is specified by
foreach
. If provided, the input to the series is frozen, and future slices do not change the partition. If omitted, the partition is initially empty set (i.e., all input data is ordered in one global partition), and all future slices are added to the partition.
Function: series along (c1 [desc](, c2 [desc])*) [foreach ([p1(, p2)*])]
Data Type: input type
Example:
See examples below
lag(input)
Returns the value of input
for the immediately preceding row within the partition, or null
for the first row in the partition. input
must be a series.
Function: lag(input)
Data Type: input type
Example:
x = Events | count by (day) | series along (day);
x - lag(x)
Result:
If x is 1,2,3: result is 1,1,1
lead(input)
Returns the value of input
for the immediately following row within the partition, or null
for the last row in the partition. input
must be a series.
Function: lead(input)
Data Type: input type
Example:
x = Events | count by (day) | series along (day);
lead(x) - x
Result:
If x is 1,2,3: result is 1,1,1
rank(input)
Returns the index (1-indexed
) of each row within its partition, ordered by collation. Within a partition, rank is unique. Ties are broken arbitrarily. input
must be a series.
Function: rank(input)
Data Type: number
Example:
x = Events | count by (day) | series along (day);
rank(x)
Result:
1,2,3