...

Formatting Report Parameters Tip or Technique Product(s): Cognos 8 BI

by user

on
Category: Documents
1

views

Report

Comments

Transcript

Formatting Report Parameters Tip or Technique Product(s): Cognos 8 BI
Tip or Technique
Formatting Report Parameters
Product(s): Cognos 8 BI
Area of Interest: Reporting
Formatting Report Parameters
2
Copyright
Copyright © 2008 Cognos ULC (formerly Cognos Incorporated). Cognos ULC
is an IBM Company. 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. Cognos does not accept
responsibility for any kind of loss resulting from the use of information
contained in this document. This document shows the publication date. The
information contained in this document is subject to change without notice.
Any improvements or changes to the information contained in this document
will be documented in subsequent editions. This document contains
proprietary information of Cognos. All rights are reserved. No part of this
document may be copied, photocopied, reproduced, stored in a retrieval
system, transmitted in any form or by any means, or translated into another
language without the prior written consent of Cognos. Cognos and the
Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated)
in the United States and/or other countries. IBM and the IBM logo are
trademarks of International Business Machines Corporation in the United
States, or other countries, or both. All other names are trademarks or
registered trademarks of their respective companies. Information about
Cognos products can be found at www.cognos.com
This document is maintained by the Best Practices, Product and Technology
team. You can send comments, suggestions, and additions to
[email protected]
Proprietary Information
Formatting Report Parameters
3
Contents
1
INTRODUCTION ............................................................................................ 4
1.1
1.2
PURPOSE .............................................................................................................. 4
APPLICABILITY ....................................................................................................... 4
2
FORMATTING PARAMETERS OVERVIEW ...................................................... 4
3
FORMATTING PARAMETERS WORKSHOP ..................................................... 5
3.1
3.2
FORMATTING A TIMESTAMP PARAMETER ........................................................................ 5
FORMATTING A NUMERIC PARAMETER ........................................................................... 9
4
TROUBLESHOOTING ................................................................................... 13
Proprietary Information
Formatting Report Parameters
4
1 Introduction
1.1
Purpose
This document was created in response to customer enhancement # 443500
which requests the ability to format parameter values displayed as Layout
Calculations. This document will describe how to apply format to parameters
displayed using Layout Calculations within Report Studio.
1.2
Applicability
The steps outlined in this document were validated using:
• IBM Cognos 8.4 build 27.73-0 against the Go Sales(query) package
provided with the samples.
The steps should also work using the IBM Cognos 8 BI 8.3 release.
2 Formatting Parameters Overview
In order to display the parameter value in the report, a Layout Calculation
object such as ParamValue('parameter_name') must be used. Due to the fact
that the data type of this calculation is of type string, any attempts to format
this calculation will not be successful. The date parameter will always display
in the format Oct 14, 2008 12:00 AM.
The technique to formatting parameters is to convert the Use value as
returned by the ParamValue( ) function into the proper non-string data type
using the report expression cast functions which were introduced in the IBM
Cognos 8 BI 8.3 release.
Proprietary Information
Formatting Report Parameters
3 Formatting Parameters Workshop
3.1
Formatting a Timestamp Parameter
The following section will provide a step by step example of how to format a
date parameter.
1. Create a new Report Studio list report with the item:
• \Inventory (Query)\Time dimension\Date.
2. Create a new detail filter: Date > ?pDate?.
3. Drop a Layout Calculation into the Page Header with the expression:
ParamValue(‘pDate’) as illustrated below.
Proprietary Information
5
Formatting Report Parameters
6
4. Run the report. When prompted change the year to 2004 and press OK. The
report should display as follows.
Notice that the date format of the pDate parameter is ISO standard
timestamp format.
5. Return to Report Studio and Edit the existing Layout Calculation by adding
the string2timestamp data type casting function. When completed the
expression should read: string2timestamp (ParamValue('pDate'))
6. Run the report. When prompted change the year to 2004 and press OK. The
report should display as follows.
Proprietary Information
Formatting Report Parameters
Notice that the date format of the pDate parameter is the default date
format.
7. Return to Report Studio and select the Layout calculation item.
8. Right click and select Style … Data Format from the available context menu.
9. Change the Format type to Date and change the Date Ordering to
Year,Month,Day as illustrated.
Proprietary Information
7
Formatting Report Parameters
8
10. Run the report. When prompted change the year to 2004 and press OK. The
report should display as follows.
Notice that the date format of the pDate parameter is the Year,Month,Day
format specified as the Date Ordering property.
Proprietary Information
Formatting Report Parameters
3.2
9
Formatting a Numeric Parameter
The following section will provide a step by step example of how to format a
numeric parameter.
1. Create a new Report Studio list report with the item:
• \Inventory (Query)\Product\Product Name
• \Inventory (Query)\Inventory\Unit cost
2. Add a new detail filter: [Unit cost] > ?pUC?. Be sure the Application property
on the filter is set to After Aggregation.
3. Drop a new text item into the header and label it ' Unit Cost: '. When
completed the report should represent the following.
Proprietary Information
Formatting Report Parameters
10
4. Drop a Layout Calculation into the Page Header with the expression:
ParamValue(‘pUC’) to the right of the previously created text item.
5. Run the report. When prompted change enter a unit cost of 20000 and press
OK. The report should display as follows.
Proprietary Information
Formatting Report Parameters
11
Notice that no format has been applied to the Unit cost parameter value.
6. Return to Report Studio and Edit the existing Layout Calculation by adding
the string2timestamp data type casting function. When completed the
expression should read: string2double (ParamValue('pUC')). For this
particular example the string2double cast was used since the pUC parameter
can accept both integer and non-integer values.
7. Right click and select Style … Data Format from the available context menu.
8. Change the Format type to Currency and change the Currency property to
$(CAD) – Canada,dollar as illustrated.
Proprietary Information
Formatting Report Parameters
12
9. Run the report. When prompted change enter a unit cost of 20000 and press
OK. The report should display as follows.
Notice that the Unit cost parameter value is now formatted as currency.
Proprietary Information
Formatting Report Parameters
4 Troubleshooting
Problem: After applying a data format to a date parameter the value is being
displayed as –.
Solution: Ensure that you are using the expression string2timestamp
(ParamValue('pDate')) not string2timestamp (ParamDisplayValue('pDate')).
Proprietary Information
13
Fly UP