Extracts the value from a column that is a specified number of rows before the current value.

prev(myNumber, 1) order:Date

Output: Returns the value in the row in the myNumber column immediately preceding the current row, when ordered by Date.

prev(col_ref, k_integer) order: order_col [group: group_col]


ArgumentRequired?Data TypeDescription
col_refYstringName of column whose values are applied to the function
k_integerYinteger (positive)Number of rows before the current one from which to extract the value

For more information on the order and group parameters, see Window Transform.

col_ref

Name of the column whose values are used to extract the value that is k-integer values before the current one.

Required?Data TypeExample Value
YesString (column reference)myColumn

k_integer

Integer representing the number of rows before the current one from which to extract the value.

 

Required?Data TypeExample Value
YesInteger4

Example - Examine prior order history