Last value: last_value
Syntax
in a Data Set expression |
last_value ( dataset over ( analyticClause ) ) |
in a Component expression within a calc clause |
last_value ( component over ( analyticClause ) ) |
Input parameters
dataset |
the operand Data Set |
component |
the operand Component |
analyticClause |
see Analytic invocation |
Semantics for scalar operations
This operator cannot be applied to scalar values.
Input parameters type
dataset
dataset { measure<scalar> _+ }
component
component<scalar>
Result type
result
dataset
| component<scalar>
Additional Constraints
The Aggregate invocation is not allowed.
Behaviour
The operator returns the last value (in the value order) of the set of Data Points that belong to the same analytic window as the current Data Point.
When invoked at Data Set level, it returns the last value for each Measure of the input Data Set. The last value of different Measures can result from different Data Points. When invoked at Component level, it returns the last value of the specified Component.
For other details, see Analytic invocation.
Examples
Given the operand dataset DS_1:
Input DS_1 (see structure)
Id_1 |
Id_2 |
Id_3 |
Me_1 |
Me_2 |
---|---|---|---|---|
A |
XX |
1993 |
3 |
1 |
A |
XX |
1994 |
4 |
9 |
A |
XX |
1995 |
7 |
5 |
A |
XX |
1996 |
6 |
8 |
A |
YY |
1993 |
9 |
3 |
A |
YY |
1994 |
5 |
4 |
A |
YY |
1995 |
10 |
2 |
A |
YY |
1996 |
2 |
7 |
Example 1
DS_r := last_value ( DS_1 over ( partition by Id_1, Id_2 order by Id_3 data points between 1 preceding and 1 following ) );
results in (see structure):
Id_1 |
Id_2 |
Id_3 |
Me_1 |
Me_2 |
---|---|---|---|---|
A |
XX |
1993 |
4 |
9 |
A |
XX |
1994 |
7 |
5 |
A |
XX |
1995 |
6 |
8 |
A |
XX |
1996 |
6 |
8 |
A |
YY |
1993 |
5 |
4 |
A |
YY |
1994 |
10 |
2 |
A |
YY |
1995 |
2 |
7 |
A |
YY |
1996 |
2 |
7 |