Online URL : http://www.lyzasoft.com/support/question.php?ID=115
PREVIOUS
Description
PREVIOUS provides a way to use a
column in one record in the record immediately following.
Syntax
PREVIOUS(column_ref,
initial_value)
Column_ref is
the column from which the value will come.
Initial_value is the value that
will be used for the calculation in the first row, where there is
obviously no preceding row to access. If not provided, initial_value defaults as follows:
| Column
Type |
Default
Value |
| TEXT
|
""
(empty
string) |
| NUMBER
|
0
(zero)
|
| DATE
|
Jan
1, 1970 |
PREVIOUS processes rows in order from first to last, so the result of a
formula or calculation on a given row will be completed before the same
formula or calculation on the subsequent row.
PREVIOUS can take text, number, or date values, and returns a value of
the same type. Thus, the value returned by PREVIOUS will always be
consistent with the type of the column it operates on.
Example
In the following example, we see
how PREVIOUS operates on a timestamp column. Successive rows in the
data represent sequential sales records, each with the time at which
the sale was recorded. We want to get the length of the time interval
between the current sale and the previous sale, so we use PREVIOUS on
the timestamp column, as shown below:
Sample
Data
Row
Num
|
Sale
Amt
|
Timestamp
|
Timestamp
- PREVIOUS(Timestamp)
|
|
NUMBER
|
DATE
|
DATE
|
1
|
120.73
|
11:02
AM
|
0
|
2
|
8.99
|
11:13
AM
|
11
minutes
|
3
|
83.47
|
11:14
AM
|
1
minute
|
4
|
28.98
|
11:16
AM
|
2
minutes
|
Back to Original Question