Go to primary content

Percent Difference from Prior Period

Returns the percent difference between the measure value of the current member and the measure value of a previous member at the same level.

The template presents a measure of the analytic view, an attribute dimension the analytic view is dimensioned by, a hierarchy that uses the attribute dimension, and a number that specifies the offset from the current member. To select a different measure, attribute dimension, hierarchy, or number, 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

Percent difference from prior period for the measure name measure for the attribute dimension alias attribute dimension and the hierarchy alias hierarchy number period ago.

Example: Example of Percent Difference from Prior Period

The sales_pct_chg_prev_yr calculates the percentage of the difference between the measure value for the current member and the measure value for the hierarchy member that is one member before the current member at the same level.

Calculation in Template

Percent difference from prior period for SALES in TIME_ATTR_DIM and TIME_HIER hierarchy 1 period ago.

Definition of Calculated Measure in Analytic View

The SALES_AV analytic view definition MEASURES clause includes this definition of the sales_pct_chg_prev_yr calculated measure:

   sales_pct_chg_prev_yr AS
     (LAG_DIFF_PERCENT(SALES) OVER (HIERARCHY time_hier OFFSET 1)

SELECT Statement Using the Calculated Measure

Query the analytic view, selecting hierarchy members, sales values, and the percent of sales for a year compared to the previous year.

-- Select the SALES and SALES_PCT_CHG_PREV_YR measures at the YEAR level.
SELECT time_hier.member_name as TIME,
  sales,
  ROUND(sales_pct_chg_prev_yr, 4) AS sales_pct_chg_prev_yr
FROM
  sales_av HIERARCHIES(time_hier)
WHERE time_hier.level_name IN ('YEAR')
ORDER BY time_hier.hier_order;

Results of the Query

TIME    SALES          SALES_PCT_CHG_PREV_YR
------  ----------     ---------------------
CY2011  6755115980.73                  (null)
CY2012  6901682398.95                  .0217
CY2013  7240938717.57                  .0492
CY2014  7579746352.89                  .0468
CY2015  7941102885.15                  .0477