Sunday 10 July 2016

Time Series Functions

Time Series Function are useful to evaluate and compare the business performance against time period, analyzing the data for multiple periods.
  1. Ago:  calculates the aggregated value from the current time back to a specified time period.
Ex: Month Ago Revenue, Year Ago Revenue
Syntax: AGO(expr, [time_level], offset)
Expr is an expression that references at least one measure column.
Time_level is Level in the Time Hierarchy, such as quarter, month, or year.
Offset is an integer literal that represents the time shift amount.
  1. ToDate: aggregates a measure attribute from the beginning of a specified time period to the current time
Ex: Year To Date Revenue (YTD), Mont To Date Revenue ( MTD)
Syntax: TODATE(expr, time_level)
  1. Periodic Rolling: This function computes the sum of a measure over the period starting offset of time and ending offset of time from the current time
Ex: 3Month Rolling Revenue
Syntax: PERIODROLLING(expr, starting period offset [,ending period offset])

Practice: (Copied from Oracle Tutorial)
Identifying a Logical Dimension as a Time Dimension
  1. Return to the Administration Tool and open the BISAMPLE repository in offline mode.
  2. In the BMM layer, double-click the H1 Time logical dimension to open the Logical Dimension dialog box.
alt description here
  1. In the Structure section, select Time.
alt description here
Time series functions operate on time-oriented dimensions. To use these functions on a particular dimension, you must designate the dimension as a Time dimension.
  1. Click OK to close the Logical Dimension dialog box.
 Identifying Level Keys as Chronological Keys
  1. Expand the H1 Time logical dimension and double-click the Time Detail level to open the Logical Level dialog box.
  2. Click the Keys tab.
alt description here
  1. Select the Chronological Key check box for Calendar Date.
alt description here


  1. Click OK to close the Logical Level dialog box.
  2. Repeat and set chronological keys for the following levels:
Logical Level
Chronological Key
Year
Per Name Year
Half
Per Name Half
Quarter
Per Name Qtr
Month
Per Name Month
Week
Per Name Week
  1. It is best practice to designate a chronological key for every level of a time logical dimension.

 Creating a Measure Using the AGO Function
  1. Right-click the F1 Revenue logical table and select New Object > Logical Column.
  2. On the General tab, name the column Month Ago Revenue.
alt description here
  1. On the Column Source tab, select "Derived from existing columns using an expression".
alt description here
  1. Open the Expression Builder.
  2. Select Functions > Time Series Functions > Ago.
alt description here
  1. Double-click Ago or click Insert selected item to add the Ago function to the Expression Builder.
alt description here
  1. Click <<Measure>>in the expression.
alt description here
  1. Select Logical Tables > F1 Revenue and then double-click Revenue to add it to the expression.
alt description here
  1. Click <<Level>> in the expression.
alt description here
  1. Select Time Dimensions > H1 Time and then double-click Month to add it to the expression.
alt description here
  1. Click <<Number of Periods>> and enter 1. The Ago function will calculate the Revenue value one month before the current month.
alt description here
  1. Click OK to close the Expression Builder. Check your work in the Logical Column dialog box:
alt description here
  1. Click OK to close the Logical Column dialog box. The Month Ago Revenue time series measure is added to the F1 Revenue logical table.
alt description here
  1. Drag the Month Ago Revenue logical column to the Base Facts presentation folder.
alt description here
 Creating a Measure Using the TODATE Function
  1. Right-click the F1 Revenue logical table and select New Object > Logical Column.
  2. On the General tab, name the new logical column Year To Date Revenue.
alt description here
  1. On the Column Source tab, select "Derived from existing columns using an expression".
alt description here
  1. Open the Expression Builder.
  2. Select Functions > Time Series Functions and double-click ToDate to insert the expression.
alt description here
  1. Click <<Measure>> in the expression.
alt description here
  1. Select Logical Tables > F1 Revenue and then double-click Revenue to add it to the expression.
alt description here
  1. Click <<Level>> in the expression.
alt description here
  1. Select Time Dimensions > H1 Time and then double-click Year to add it to the expression.
alt description here
  1. Click OK to close the Expression Builder.
  2. Check your work in the Logical Column dialog box.
alt description here
  1. Click OK to close the Logical Column dialog box.
  2. Drag the Year To Date Revenue logical column to the Base Facts presentation folder.
alt description here
 Creating a Measure Using the PERIODROLLING Function
  1. Right-click the F1 Revenue logical table and select New Object > Logical Column.
  2. On the General tab, name the new logical column Revenue 3-Period Rolling Sum.
alt description here
  1. On the Column Source tab, select "Derived from existing columns using an expression".
alt description here
  1. Open the Expression Builder.
  2. Select Functions > Time Series Functions and double-click PeriodRolling to insert the expression.
alt description here
  1. Click <<Measure>> in the expression.
alt description here
  1. Select Logical Tables > F1 Revenue and then double-click Revenue to add it to the expression.
alt description here
  1. Click <<Starting Period Offset>> in the expression.
alt description here
  1. Enter -2. This identifies the first period in the rolling aggregation.
alt description here
  1. Click <<Ending Period Offset>>.
alt description here
  1. Enter 0. This identifies the last period in the rolling aggregation.
alt description here
These integers are the relative number of periods from a displayed period. In this example, if the query grain is month, the 3 month rolling sum starts two months in the past (-2) and includes the current month (0).
  1. Click OK to close the Expression Builder.
  2. Check your work in the Logical Column dialog box.
alt description here
  1. Click OK to close the Logical Column dialog box.
  2. Drag the Revenue 3-Period Rolling Sum logical column to the Base Facts presentation folder.
alt description here
  1. Save the repository and check consistency. Fix any errors or warnings before you proceed.
  2. Close the repository. Leave the Administration Tool open.
 Testing Your Work
  1. Return to Oracle Enterprise Manager and load the BISAMPLE repository.
  2. Return to Oracle BI and sign in.
  3. Create the following analysis to test AGO and TODATE functions:
Time.Per Name Month
Time.Per Name Year
Base Facts.Revenue
Base Facts.Month Ago Revenue
Base Facts.Year to Date Revenue
alt description here
  1. Set the following filter for the analysis:
Per Name Year is equal to / is in 2008.
alt description here
  1. For the Per Name Year column, select Column Properties > Column Format > Hide. This will prevent Per Name Year from displaying in the analysis results.
alt description here
  1. Sort Per Name Month in ascending order.
alt description here
  1. Click Results.
alt description here
Month Ago Revenue displays revenue from the previous month. Year To Date Revenue calculates a running sum of revenue for the year on a monthly basis.
  1. Create the following new analysis and filter to test the PERIODROLLING function at the month grain:
Time.Per Name Month
Time.Per Name Year
Base Facts.Revenue
Base Facts.Revenue 3-Period Rolling Sum
Per Name Year is equal to / is in 2008
alt description herealt description here
  1. For the Per Name Year column, select Column Properties > Column Format > Hide. This will prevent Per Name Year from displaying in the analysis results.
alt description here
  1. Sort Per Name Month in ascending order.
alt description here
  1. Click Results.
alt description here
Revenue 3-Period Rolling Sum is calculated based on the month grain.
  1. Create the following new analysis and filter to test the PERIODROLLING function at the year grain:
Time.Per Name Year
Base Facts.Revenue
Base Facts.Revenue 3-Period Rolling Sum
alt description here
  1. Sort Per Name Year in ascending order.
alt description here
  1. Click Results.
alt description here

Revenue 3-Period Rolling Sum is calculated based on the year grain. A measure with the PERIODROLLING function calculates results based on the query grain.

No comments:

Post a Comment