Oracle® OLAP Expression Syntax Reference Release 11.2 E23381-01 |
|
|
PDF · Mobi · ePub |
LAG_VARIANCE
returns the difference between values for the current time period and an earlier period.
The same data type as the value expression
LAG_VARIANCE (lag_args) OVER (lag_clause)
lag_args::=
expression, offset [, {default_expression | CLOSEST} ]
lag_clause::=
[ {DIMENSION dimension_id | HIERARCHY hierarchy_id} ] [ [BY] { LEVEL | PARENT | GREGORIAN {YEAR | QUARTER | MONTH | WEEK | DAY} | ANCESTOR AT { DIMENSION LEVEL dim_level_id | HIERARCHY LEVEL hier_level_id } } [POSITION FROM {BEGINNING | END}] ]
A dimensional expression whose values you want to calculate.
A numeric expression for the number of periods to count back from the current time period.
The value returned when offset
does not identify a valid period. This clause is either an expression of any data type or the CLOSEST
keyword for the closest match. The closest match is the first member when counting back.
The Time dimension over which the lag is calculated.
The hierarchy over which the lag is calculated. Otherwise, the default hierarchy for dimension_id
is used.
The name of a level of dimension_id
.
The name of a level of hierarchy_id
.
The BY subclause identifies the range of time periods used when counting the offset. Following are descriptions of the keywords:
Offset Unit | Description |
---|---|
LEVEL |
The member at the same level offset periods before the current member. (Default) |
PARENT |
The member at the same level with the same parent offset periods before the current member. |
GREGORIAN YEAR |
The period at the same level with a start date exactly offset years before the start date of the current period. |
GREGORIAN QUARTER |
The period at the same level with a start date exactly offset quarters before the start date of the current period. |
GREGORIAN MONTH |
The period at the same level with a start date exactly offset months before the start date of the current period. |
GREGORIAN WEEK |
The period at the same level with a start date exactly offset weeks before the start date of the current period. |
GREGORIAN DAY |
The period at the same level with a start date exactly offset days before the start date of the current period. |
ANCESTOR |
The period at the same level as the current period and whose ancestor is offset positions before the ancestor of the current period. |
This example returns the difference in values between the current period and the equivalent period in the prior year.
LAG_VARIANCE (GLOBAL.UNITS_CUBE.UNITS, 1) OVER (HIERARCHY GLOBAL.TIME.CALENDAR ANCESTOR AT DIMENSION LEVEL GLOBAL.TIME.CALENDAR_YEAR)
Time | Units | Last Year | Difference |
---|---|---|---|
Q1.05 | 143607 | 146529 | -2922 |
Q2.05 | 138096 | 143070 | -4974 |
Q3.05 | 138953 | 148292 | -9339 |
Q4.05 | 145062 | 149528 | -4466 |
Q1.06 | 146819 | 143607 | 3212 |
Q2.06 | 145233 | 138096 | 7137 |
Q3.06 | 143572 | 138953 | 4619 |
Q4.06 | 149305 | 145062 | 4243 |