Book Image

IBM Cognos 10 Report Studio Cookbook, Second Edition - Second Edition

Book Image

IBM Cognos 10 Report Studio Cookbook, Second Edition - Second Edition

Overview of this book

IBM Cognos Report Studio is widely used for creating and managing business reports in medium to large companies. It is simple enough for any business analyst, power user, or developer to pick up and start developing basic reports. However, this book is designed to take the reader beyond the basics and into the world of creating more sophisticated, functional business reports.IBM Cognos 10 Report Studio Cookbook, Second Edition helps you understand and use all the features provided by Report Studio to generate impressive deliverables. It will take you from being a beginner to a professional report author. It bridges the gap between basic training provided by manuals or trainers and the practical techniques learned over years of practice.Written in a recipe style, this book offers step-by-step instructions for IBM Cognos Report Studio users to author reports effectively, allowing a reader to dip in and out of the chapters as they desire. You will see a new fictional business case in each recipe that will relate to a real-life problem and then you will learn how to crack it in Report Studio. This book covers all the basic and advanced features of Report Authoring. It introduces the fundamental features useful across any level of reporting. Then it ascends to advanced techniques and tricks to overcome Studio limitations. Develop excellent reports using dimensional data sources by following best practices that development work requires in Report Studio. You will also learn about editing the report outside the Studio by directly editing the XML specifications. You will discover how to build and use Cognos Active Reports, a new addition in IBM Cognos 10. Provide richness to the user interface by adding JavaScript and HTML tags and using the different chart types introduced in IBM Cognos 10. The main focus is on the practical use of various powerful features that Report Studio has to offer to suit your business requirements. Learn numerous techniques and hacks that will allow you to make the best out of your IBM Cognos 10 Report Studio.
Table of Contents (21 chapters)
IBM Cognos 10 Report Studio Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Formatting data – dates, numbers, and percentages


Virtually all reports involve displaying numerical information. It is very important to correctly format the numbers. In this recipe, we will create a report which formats dates, numbers, and percentages.

Date transformation and formatting are important in business reports. We will see two ways of displaying MONTH-YEAR from the Shipment Date Key. We will apply some formatting to a numeric column and will also configure a ratio to be displayed as a percentage.

Getting ready

Create a simple list report with Products / Product line, Products / Product type, and Time (ship date) / Date (ship date) as columns from the Sales (query) namespace.

Also, add Quantity , Unit price, and Unit cost from the Sales fact Query Subject.

Create a grouping on Product line and Product type.

How to do it...

In this recipe, we will check how to apply different formats on the data items.

  1. We will start by formatting the date column we have (check in Cognos 8).

  2. Select the Time (ship date) / Date (ship date) column and open Data Format from the Properties pane. Open the Data Format dialog box by clicking on the Browse button next to the Data Format property.

  3. Choose the format type Date, set Date Style to Medium, and set Display Days to No, as shown in the following screenshot:

  4. Now select the Quantity column in the report. Choose Data Format from property and open the dialog box again.

  5. This time select Number as the type and set the different properties as required. In our example recipe, we will set the Number of Decimal Points to 2 and use brackets () as a Negative Sign Symbol.

  6. Finally, we will add the ratio calculation to the report. For that, add a new query calculation and define it as follows:

    [Unit price]/[Unit cost]
  7. Select this column and from the Data Format property dialog box, set it as Percent. Choose % as the Percentage Symbol and set the Number of Decimal Places to 2. Also, set the Divide by Zero Characters to N/A.

  8. Run the report to test it.

How it works...

In this recipe, we are trying multiple techniques. We are checking how dates can be formatted to hide certain details (for example, days) and how to change the separator. Also, we have tested formatting options for numbers and the percentage.

Date format

Here, we started by setting the data format for the Month Year column as date for display purposes. We have set the display days to No as we only want to display MONTH-YEAR.

Numerical format

This is straightforward. The quantity column is displayed with two decimal points and negative numbers are displayed in brackets as this is what we have set the data formatting to.

The % margin

The ratio of unit price to unit cost is calculated by this item. Without formatting, the value is simply the result of a division operation. By setting the data format to Percent, Cognos automatically multiplies the ratio by 100 and displays it as a percentage.

There's more...

Please note that ideally the warehouse stores a calendar table with a Date type of field; this is made available through the Framework model. Also, we are assuming here that you need to see the shipment month. So, you want to see the MONTH-YEAR format only and we are hiding the days.

Using the data format options, you can do a lot of things. Assume that you don't have a date field in your data source but instead you have just a date key and you want to display the year and month as we did in our recipe. For that, create a new query calculation and use the following expression:

[Sales (query)].[Time (ship date)].[Day key (ship date)]/10000

Now set the Data Format to Number with the following options:

  • Set the No of decimal places field to 2

  • Set the Decimal separator to -

  • Set Use thousand separator to No

Run the report to examine the output. You will see that we have gotten rid of the last two digits from the day key and the year part is separated from the month part by a hyphen. This is not truly converted to MONTH-YEAR, but conveys the information as shown in the following screenshot:

The advantage here is that the numerical operation is faster than converting the numerical key to DATE. We can use similar techniques to cosmetically achieve the required result.