Series functions

  • Updated

This page outlines a series of functions you can invoke using NetScript.

series along (c1 [desc](, c2 [desc])) [foreach ([p1(, p2)])]

Use the series function to declare that your input data is logically ordered according to each partition's specified collation (c1, c2, and so on). Define the partition using distinct tuples of values (p1, p2, and so on)

  • (Required) Collation, specified by "along," requires at least one input. If you have ties, use c2 and beyond.
  • (Optional) Specify the partition with "foreach."
    • If you do specify, the input to the series becomes static, and future slices do not alter the partition.
    • If you omit the partition, it starts as an empty set, ordering all input data in one global partition, and you add future slices to this partition.

Function

series along (c1 [desc](, c2 [desc])*) [foreach ([p1(, p2)*])]

Data type – input type

Example

See the following examples

lag(input)

Use the lag function to get the input value for the immediately preceding row within the partition, or null for the first row. Ensure your input is 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)

Use the lead function to get the input value for the following row within the partition, or null for the last row. Ensure your input is 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)

Use the rank function to find each row's index (1-indexed) within its partition, ordered by collation. The rank is unique within a partition, and ties are broken arbitrarily. Ensure your input is a series.

Function

rank(input)

Data type – Number

Example

x = Events | count by (day) | series along (day);
rank(x)

Result

1,2,3