Calculates the values up to the previous period within an ancestor or within a level.
The template presents an ancestor or a level for a measure of the analytic view, an attribute dimension the analytic view is dimensioned by, a hierarchy that uses the attribute dimension, an aggregation operator, and the beginning or end of the period. To select a different value for an option, click the underlined value in the template and make a selection from the Select Measures dialog box or the drop-down list or enter a different number value.
Template
{ Level | parent | ancestor at level level name } to date number period ago for the measure name measure for the attribute dimension alias attribute dimension and the hierarchy alias hierarchy. Aggregate using { SUM | MAXIMUM | MINIMUM |AVERAGE } from the { beginning | end } of the period.
Example: Example of Period To Date Period Ago
The sales_to_date_yr_ago calculated measure calculates a running total of the SALES measure values for the hierarchy members that have the same ancestor at the year level from the beginning of the period to the current member.
Calculation in Template
Ancestor at level YEAR to date 1 period ago for the SALES measure in the TIME_ATTR_DIM attribute dimension and TIME.HIER hierarchy. Aggregate using SUM from the beginning of the period.
Definition of Calculated Measure in Analytic View
The MEASURES clause of the SALES_AV analytic view definition includes this definition of the sales_to_date_yr_ago calculated measure:
sales_to_date_yr_ago AS
LAG (
SUM(SALES)
OVER (HIERARCHY TIME_ATTR_DIM.TIME_HIER
BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER
WITHIN ANCESTOR AT LEVEL YEAR))
OVER (HIERARCHY TIME_ATTR_DIM.TIME_HIER OFFSET 1)
SELECT Statement Using the Calculated Measure
Query the analytic view, selecting sales and sales_to_date_yr_ago values.
SELECT time_hier.member_name as TIME,
sales,
sales_to_date_yr_ago
FROM
sales_av HIERARCHIES(time_hier)
WHERE time_hier.level_name IN ('YEAR', 'QUARTER')
ORDER BY time_hier.hier_order;
Results of the Query
TIME SALES SALES_TO_DATE_YR_AGO -------- ---------- -------------------- CY2011 6755115981 (null) Q1CY2011 1625299627 (null) Q2CY2011 1715160208 1625299627 Q3CY2011 1691017693 3340459835 Q4CY2011 1723638452 5031477528 CY2012 6901682399 6755115981 Q1CY2012 1644857783 6755115981 Q2CY2012 1752414182 1644857783 Q3CY2012 1732373412 3397271965 Q4CY2012 1772037022 5129645377 CY2013 7240938718 6901682399 Q1CY2013 1723571458 6901682399 Q2CY2013 1840985832 1723571458 Q3CY2013 1821918664 3564557290 Q4CY2013 1854462764 5386475954 CY2014 7579746353 7240938718 Q1CY2014 1809855822 7240938718 Q2CY2014 1929427229 1809855822 Q3CY2014 1900013511 3739283051 Q4CY2014 1940449791 5639296562 CY2015 7941102885 7579746353 Q1CY2015 1908099573 7579746353 Q2CY2015 2018132033 1908099573 Q3CY2015 1989225699 3926231605 Q4CY2015 2025645581 5915457304
Parent topic: Period To Date