Skip to content
Reference > Prepare Methods

offset(value,offset)

Definition

Object offset(Object value, Integer offset)

Description

Will grab the value offset from the current row. If offset==0 use current row, negative number is nth prior row, positive number is nth future row. Evaluates to null if offset is out of bounds for current table. Ex: offset(price,-1) for first row returns null, for second row returns first Row's price and for nth row returns (n-1)ths row's price

Parameter Definition

Name Type Description
value Object
offset Integer

Example

Prepare *,offset(Price,-1) as Sample from SampleData Partition by Symbol
+------+--------+-----+------+
|Symbol|Sequence|Price|Sample|
+------+--------+-----+------+
|CAT   |1       |50.0 !null  |
|CAT   |2       |54.0 |50.0  |
|CAT   |3       |52.0 |54.0  |
|CAT   |4       |52.0 |52.0  |
|CAT   |5       !null |52.0  |
|CAT   |6       |57.0 !null  |
|IBM   |1       |20.0 !null  |
|IBM   |2       |24.0 |20.0  |
|IBM   |3       |22.0 |24.0  |
|IBM   |4       |27.0 |22.0  |
|IBM   |5       !null |27.0  |
+------+--------+-----+------+