Friday, September 1, 2017

How to author Cognos complicated crosstab with multiple measures and different calculation based on DMR

1         Problem

This report below illustrates some special requests:
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0OEa8Im-Y-y079jyWeSerBJfIINQplpIhGhlQ1Xa6Xg0ocVA-MazR8MkeuECrj8LReZDVXTK3sPC_euaTfUhiL-gr0IDzEsqrVcvFlfSXOoI3v1osROHeMpCPmtpzBAAJ-yCNBEK63z23/s1600/1.png

1)     There are different measures located on rows and based on two group. The first row is total, while all others is a sub group;
2)     different columns are specified with three different granularities: a. two months, b) Month difference and c) all values are based on total, not sub group, which is different from two months.
3)     With respect to Month difference, there are different calculation, such as simple A-B and (A-B)/B.
4)     Some obvious override apply for the format for crosstab.
2         Analysis
This crosstab is not easy to build, as the granularity are different in both directions, columns and rows. One of solutions is to use crosstab override, which is approved very difficult. Another solution is to use singleton, but the problem is that each singleton in general need to a separated query. As it is so many cells to override, we need to have many queries to create. This solution is not practical either. The goal is look into a solution with one query and gets all data.
3         Solution
According to the goal with clear structure, we need to break crosstab into two different sub crosstabs, and break crosstab with more columns as needed, and then STITCH them together.
Layout:https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9mjl8jgd9kFooCBtVbuAAkXNA4UNfK1netXQ1S_9YasSzUk7nL493gBhlYneLP1rik_v05AvmXV0lIKxaxOAftSpNz7yGAMLQnp6pZSCsQAidnKrRTHal9JXQYx5AeFLD20hhJSuE-J9K/s1600/2.png



Single Query:
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl8EbALCN3VVq5c-ISTAKOjaXdq_iV5FaxVW4dlQEHjaJpb1VKBzA__3hi9OOqtyzGXd4j6TvchjEO5LYTa2KSPknSRspKlJQRrjgEEDvvnlRrCeqyIV1lN2p_-7sR28-WlhfApkZvIg1u/s1600/3.png

A few practical ideas are derived below:
1)     Use crosstab node is resolve different granularities for columns, such as break down and crosstab space as total
2)     Use different sub crosstabs to make crosstab handle different  granularities.
3)     Use different columns to calculate different granularities and then put it together with show/hidden to avoid crosstab override.
4)     As each data container (list, crosstab and chart) generates different SQLs, we can use the same query to perform multiple data sets. Please note that singleton is different from list, crosstab and chart, as singleton requests a separated Cognos Query.

No comments:

Post a Comment