Sunteți pe pagina 1din 10

Tip or Technique

Conditional Business Reporting


Based on Relative and Absolute
Dates within IBM Cognos Report
Studio
Product(s): IBM Cognos BI

Area of Interest: Reporting


Conditional Business Reporting Based On Relative and Absolute 2
Dates within IBM Cognos Report Studio

Copyright and Trademarks


Licensed Materials - Property of IBM.

© Copyright IBM Corp. 2011

IBM, the IBM logo, and Cognos are trademarks or registered trademarks of
International Business Machines Corp., registered in many jurisdictions worldwide.
Other product and service names might be trademarks of IBM or other companies. A
current list of IBM trademarks is available on the Web at
http://www.ibm.com/legal/copytrade.shtml

While every attempt has been made to ensure that the information in this document
is accurate and complete, some typographical errors or technical inaccuracies may
exist. IBM does not accept responsibility for any kind of loss resulting from the use of
information contained in this document. The information contained in this document
is subject to change without notice.

This document is maintained by the Best Practices, Product and Technology team.
You can send comments, suggestions, and additions to cscogpp@ca.ibm.com.

Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft
Corporation in the United States, other countries, or both.
.

Business Analytics
Conditional Business Reporting Based On Relative and Absolute 3
Dates within IBM Cognos Report Studio

Contents
1 INTRODUCTION..............................................................................................4
1.1 PURPOSE..................................................................................................................4
1.2 APPLICABILITY.............................................................................................................4
1.3 ASSUMPTIONS.............................................................................................................4
1.4 CAVEATS AND EXCEPTIONS...............................................................................................4
2 CREATING THE IBM COGNOS REPORT STUDIO REPORT...............................5
2.1 BUILDING THE LIST......................................................................................................5
2.2 CREATING THE VALUE PROMPT..........................................................................................6
2.3 CREATING THE FILTER CONDITION......................................................................................7
2.4 SCHEDULING THE REPORTS..............................................................................................9

Business Analytics
Conditional Business Reporting Based On Relative and Absolute 4
Dates within IBM Cognos Report Studio

1 Introduction

1.1 Purpose
This document describes an approach to present a ‘relative date’ to a report
consumer within a prompt or set of prompts. Many organizations might need
relative date’s activity such as the activity in the last 7 days, Month to date,
Year to Date.

1.2 Applicability
The techniques outlined in this document were validated against the GO Data
Warehouse (query) package shipped with the samples for the following
releases:
• IBM Cognos 8.4
• IBM Cognos 8.4.1
• IBM Cognos 10.1

1.3 Assumptions
This document assumes that its reader has an understanding of the IBM
Cognos Report Studio functionality and therefore will not provide the
individual steps required for basics tasks.

1.4 Caveats and Exceptions


The samples database used within this document contains values between
01-01-2004 to 31-12-2007. Due to this the current date has been hard
coded 17-05-2007. To make the techniques in this document dynamic, the
hard coded value of 17-05-2007 could be replaced with a vendor specific date
function.

Business Analytics
Conditional Business Reporting Based On Relative and Absolute 5
Dates within IBM Cognos Report Studio

2 Creating the IBM Cognos Report Studio Report

The following sections step a user through the creation of the simple list, the
parameter with static values, the filter object and the conditional formatting.

2.1 Building the List


1. Create a list using ‘GO Data Warehouse (query)’ package. For this example a
simple list was creating by selecting the following objects from the
Sales(query) namespace:
• Product\Product line
• Time dimension\Date
• Sales fact\Quantity
• Sales fact\Revenue
• Sales fact\Gross profit

Figure 1 IBM Cognos Report Studio displaying a list report with the aforementioned
query items.

Business Analytics
Conditional Business Reporting Based On Relative and Absolute 6
Dates within IBM Cognos Report Studio

2.2 Creating the Value Prompt


1. Add a value prompt to the report page. Name the parameter Relative Date
and click the “Finish” button.

Figure 2 IBM Cognos Report Studio with the Prompt Wizard- Value Prompt dialog box
displaying the new parameter name as Relative Date.

2. Create static choices corresponding to the periods needed using the


appropriate use and display values. For this example the use and display
values will be as follows:

Use Display
7d Last 7 days
MTD Month to Date
YTD Year to Date

Business Analytics
Conditional Business Reporting Based On Relative and Absolute 7
Dates within IBM Cognos Report Studio

When completed the Static Choices dialog box should represent the following
screen capture.

Figure 3 IBM Cognos Report Studio Static Choices dialog box displaying the Last 7
days, Month to Date and Year to Date static choices.

2. Change the Auto-Submit property of the prompt from No to Yes. This will
submit the prompt automatically every time the value prompt is changed.
3. Change the Required property of the prompt from Yes to No.

2.3 Creating the Filter Condition


1. Create the following detail filter which uses the static values in the previously
defined prompt to determine which date range to filter the date column.

case when ?Relative Date?='7d'

then ( [Date] between _add_days(2007-05-17,-7) and (2007-05-17))

when ?Relative Date? ='MTD'

then( [Date] between _first_of_month(2007-05-17) and (2007-05-17))

when ?Relative Date? ='YTD'

then( [Date] between _add_days(2007-05-17,((_day_of_year(2007-05-17)-


1)*-1)) and (2007-05-17))

end

Business Analytics
Conditional Business Reporting Based On Relative and Absolute 8
Dates within IBM Cognos Report Studio

In order to make this filter condition dynamic the hard coded date of 2007-
05-17 could be replaced with a vendor specific time function which retrieves
the current date at the time of execution.

Figure 4 IBM Cognos Report Studio detail filter dialog box displaying the case when
filter definition.

2. Change the Usage property on the detail filter from Required to Optional.
3. If the report is executed at this point it will produce the following output. In
order to prove that the filter is working a layout calculation of
ParamDisplayValue('Relative Date') has been added beside the value prompt.

Figure 5 IBM Cognos Viewer displaying the list output in HTML format for the Last 7
days time period.
Business Analytics
Conditional Business Reporting Based On Relative and Absolute 9
Dates within IBM Cognos Report Studio

If the prompt is changed, the screen automatically refreshes with the data
and the layout calculation reflecting the new time period.

Figure 6 IBM Cognos Viewer displaying the list output in HTML format for the Year to
Date time period after the user changed the prompt value.

2.4 Scheduling the Reports

In many cases, it is required to have reports that are run and/or distributed
on a schedule. We can leverage the relative date concept for report
scheduling.

1. In order to do that, create three new Report Views corresponding to three


reporting periods.

Figure 7 IBM Cognos Connection displaying a report view for each of the three
reporting periods.

2. From IBM Cognos Connection, create a new schedule for the Relative Dates
(Last 7 Days). In the schedule, set Frequency to By Week, Every (1) Week on
Monday, and set the Prompt Values to Over ride Default values and when the
report prompts are presented, choose Last 7 Days. Then choose a starting
date.

Business Analytics
Conditional Business Reporting Based On Relative and Absolute 10
Dates within IBM Cognos Report Studio

In this example an IBM Cognos Report Administrator has setup the Last 7
day report that would run every Monday morning.

Figure 8 IBM Cognos Schedule Management displaying a schedule for the Last 7 day
reporting period.

Business Analytics

S-ar putea să vă placă și