Page561 PDF
Page561 PDF
02 May 2011
A technique using dimensional functions to determine the current period for a multidimensional
data source, OLAP or Dimensionally Modeled Relational (DMR), where the current period has
not been defined in the data source itself.
View more content in this series
Introduction
Purpose
This document describes a technique using dimensional functions to determine the current period
for a multidimensional data source, OLAP or Dimensionally Modeled Relational (DMR), where the
current period has not been defined in the data source itself.
Applicability
This technique uses standard Dimensional Functions available within Report Studio. The
examples in this document were tested against IBM Cognos BI versions 8.4.x, and 10.1 using the
Sales and Marketing sample PowerCube distributed with the product.
Overview
Report Authors are often faced with OLAP or Dimensionally Modeled Relational (DMR) data
sources where the current period is not defined within the data source. Reports may require the
use of the current period. The method for determining the current period varies depending on how
the cube was built or the DMR was populated.
Copyright IBM Corporation 2011
IBM Cognos Proven Practices: IBM Cognos BI Using
Dimensional Functions to Determine Current Period
Trademarks
Page 1 of 6
developerWorks
ibm.com/developerWorks/
If the data source's time dimension ends at the current period, then an author can simply use
the closingPeriod dimensional function to obtain the last period for any given level in the time
hierarchy. If the data source was built with a time dimension that has future periods, then
determining the current period can be accomplished with a filter if the data contains a measure that
has data that only goes up to the current period.
This document will illustrate these two scenarios.
Illustration 1: Sales and Marketing (cube) showing the year 2007 as the last
member of the Year level in the Time dimension
The closingPeriod function can be used to return the year 2007 if you provide the Year level as the
argument for the function as seen below and in Illustration 2.
closingPeriod([sales_and_marketing].[Time].[Time].[Year])
Page 2 of 6
ibm.com/developerWorks/
developerWorks
The result of this function returns the 2007 member from the Year level as shown in Illustration 3.
Illustration 3: Cognos Viewer showing the 2007 member returned from the
Year level of the Time dimension
This function can be used for any level within the dimension. For example, you can use the Month
level as shown below.
closingPeriod ([sales_and_marketing_cs].[Time].[Time].[Month])
In this example, when the Month level is used, the 2007/Dec member is returned as seen in
Illustration 4.
Illustration 4: Cognos Viewer showing the 2007/Dec member returned from the
Month level of the Time dimension
Page 3 of 6
developerWorks
ibm.com/developerWorks/
For example, the Sales and Marketing (cube) sample has members in the Month level from
January to December for the year 2007, but only has revenue values up to July of 2007 as seen in
Illustration 5.
The result of the Current Period data item in this example returns the 2007/Jul member as seen in
Illustration 6.
Illustration 6: Crosstab report showing only data for the 2007/Jul member
2. Filter the set of Months to find the members that have data for a measure you know only goes
up to the current period, in this case Revenue.
filter(members([sales_and_marketing].[Time].[Time].[Month]), tuple([Revenue],
currentMember([sales_and_marketing].[Time].[Time])) is not null)
This allows you to display any measure or measures you wish in the report regardless if they
go beyond the current period (sales targets for example). You could also use currentMeasure
in the expression, but you would need to ensure that it is the default measure of the crosstab
or chart report and that the data for that measure does not go beyond the current period.
3. Get the last month that has data. The tail function returns a member set. In this case only one
member is returned since the integer argument is 1.
tail(filter(members([sales_and_marketing].[Time].[Time].[Month]), tuple([Revenue],
currentMember([sales_and_marketing].[Time].[Time])) is not null), 1)
IBM Cognos Proven Practices: IBM Cognos BI Using
Dimensional Functions to Determine Current Period
Page 4 of 6
ibm.com/developerWorks/
developerWorks
4. Because the desired result is a single member, the item function is used passing 0 as its
index value argument to return only the current period member.
item(tail(filter(members([sales_and_marketing].[Time].[Time].[Month]),
tuple([Revenue], currentMember([sales_and_marketing].[Time].[Time])) is not null),
1), 0)
Returning a member is important if you want to use this data item in another dimensional
function. For example, you may want to display the current period and the same period from
the previous year using the parallelPeriod function. In this case, your Current Period data item
must return a member since the parallelPeriod function expects a member as an argument as
shown below.
parallelPeriod([sales_and_marketing].[Time].[Time].[Year], 1, [Current Period])
Page 5 of 6
developerWorks
ibm.com/developerWorks/
Page 6 of 6