Book Image

IBM Cognos 8 Report Studio Cookbook

By : Abhishek Sanghani
Book Image

IBM Cognos 8 Report Studio Cookbook

By: Abhishek Sanghani

Overview of this book

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, when it comes to developing more sophisticated, fully functional business reports for wider audiences, report authors will need guidance. This book 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. This book covers all the basic and advanced features of Report Authoring. It begins by bringing readers on the same platform and introducing 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. Provide richness to the user interface by adding JavaScript and HTML tags. The main focus is on the practical use of various powerful features that Report Studio has to offer to suit your business requirements.
Table of Contents (18 chapters)
IBM Cognos 8 Report Studio Cookbook
Credits
About the Author
About the Reviewers
Preface
Index

Implementing IF THEN ELSE in filters


Business owners want to see the sales quantity by order methods. However, for the 'Sales Visit' type of order method, they want a facility to select the retailer.

Therefore, the report should show quantity by order methods. For the order methods other than 'Sales Visit', the report should consider all the retailers. For 'Sales Visit' orders, it should filter on the selected retailer.

Getting ready

Create a simple list report with Order Method | Order Method and Sales Fact | Sales Quantity as columns. Group by order method to get one row per method and set the aggregation for quantity to TOTAL.

How to do it...

  1. Here we need to apply the retailer filter only if Order Method is 'Sales Visit'. So, we start with adding a new detail filter.

  2. Define the filter as: if ([Order method]='Sales visit') then ([Sales (query)].[Retailer site].[Retailer name] = ?SalesVisitRetailer?)

  3. Validate the report. You will find multiple error messages.

  4. Now change filter definition to this: (([Order method]='Sales visit') and ([Sales (query)].[Retailer site].[Retailer name] = ?SalesVisitRetailer?)) or ([Order method]<>'Sales visit')

  5. Validate the report and it will be successful.

  6. Run the report and test the data.

How it works...

The IF ELSE construct works fine when it is used in data expression. However, when we use it in a filter, Cognos often doesn't like it. It is strange because the filter is parsed and validated fine in the expression window and IF ELSE is a valid construct.

The workaround for this problem is to use the pair of AND..OR as shown in this recipe. The IF condition and corresponding action item are joined with AND clause. The ELSE part is taken care by OR operations with the reverse condition (in our example, Order Method <> 'Sales Visit').

There's more...

You need not use both AND and OR clauses all the time. The filtering in this example can also be achieved by this expression:

([Sales (query)].[Retailer site].[Retailer name] = ?SalesVisitRetailer?)

or

([Order method]<>'Sales visit')

Depending on the requirement, you need to use only OR, only AND, or the combination of AND..OR.

Make sure that you cover all the possibilities.